android_kernel_xiaomi_sm7250/crypto/shash.c
UtsavBalar1231 e6c876d8b8 Merge tag 'ASB-2021-08-05_4.19-stable' of https://github.com/aosp-mirror/kernel_common into android12-base
https://source.android.com/security/bulletin/2021-08-01
CVE-2020-14381
CVE-2021-3347
CVE-2021-28375

* tag 'ASB-2021-08-05_4.19-stable' of https://github.com/aosp-mirror/kernel_common:
  Linux 4.19.200
  ARM: dts: versatile: Fix up interrupt controller node names
  cifs: fix the out of range assignment to bit fields in parse_server_interfaces
  firmware: arm_scmi: Fix range check for the maximum number of pending messages
  firmware: arm_scmi: Fix possible scmi_linux_errmap buffer overflow
  hfs: add lock nesting notation to hfs_find_init
  hfs: fix high memory mapping in hfs_bnode_read
  hfs: add missing clean-up in hfs_fill_super
  sctp: move 198 addresses from unusable to private scope
  net: annotate data race around sk_ll_usec
  net/802/garp: fix memleak in garp_request_join()
  net/802/mrp: fix memleak in mrp_request_join()
  workqueue: fix UAF in pwq_unbound_release_workfn()
  af_unix: fix garbage collect vs MSG_PEEK
  net: split out functions related to registering inflight socket files
  KVM: x86: determine if an exception has an error code only when injecting it.
  iio: dac: ds4422/ds4424 drop of_node check
  selftest: fix build error in tools/testing/selftests/vm/userfaultfd.c
  ANDROID: staging: ion: move buffer kmap from begin/end_cpu_access()
  Linux 4.19.199
  xhci: add xhci_get_virt_ep() helper
  spi: spi-fsl-dspi: Fix a resource leak in an error handling path
  PCI: Mark AMD Navi14 GPU ATS as broken
  btrfs: compression: don't try to compress if we don't have enough pages
  iio: accel: bma180: Fix BMA25x bandwidth register values
  iio: accel: bma180: Use explicit member assignment
  net: bcmgenet: ensure EXT_ENERGY_DET_MASK is clear
  net: dsa: mv88e6xxx: use correct .stats_set_histogram() on Topaz
  KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped()
  KVM: do not allow mapping valid but non-reference-counted pages
  KVM: do not assume PTE is writable after follow_pfn
  drm: Return -ENOTTY for non-drm ioctls
  nds32: fix up stack guard gap
  selftest: use mmap instead of posix_memalign to allocate memory
  ixgbe: Fix packet corruption due to missing DMA sync
  media: ngene: Fix out-of-bounds bug in ngene_command_config_free_buf()
  tracing: Fix bug in rb_per_cpu_empty() that might cause deadloop.
  usb: dwc2: gadget: Fix sending zero length packet in DDMA mode.
  USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick
  USB: serial: cp210x: fix comments for GE CS1000
  USB: serial: option: add support for u-blox LARA-R6 family
  usb: renesas_usbhs: Fix superfluous irqs happen after usb_pkt_pop()
  usb: max-3421: Prevent corruption of freed memory
  USB: usb-storage: Add LaCie Rugged USB3-FW to IGNORE_UAS
  usb: hub: Fix link power management max exit latency (MEL) calculations
  usb: hub: Disable USB 3 device initiated lpm if exit latency is too high
  KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
  xhci: Fix lost USB 2 remote wake
  ALSA: sb: Fix potential ABBA deadlock in CSP driver
  ALSA: usb-audio: Add registration quirk for JBL Quantum headsets
  s390/ftrace: fix ftrace_update_ftrace_func implementation
  Revert "MIPS: add PMD table accounting into MIPS'pmd_alloc_one"
  proc: Avoid mixing integer types in mem_rw()
  drm/panel: raspberrypi-touchscreen: Prevent double-free
  net: sched: cls_api: Fix the the wrong parameter
  sctp: update active_key for asoc when old key is being replaced
  Revert "USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem"
  nvme-pci: don't WARN_ON in nvme_reset_work if ctrl.state is not RESETTING
  net/sched: act_skbmod: Skip non-Ethernet packets
  net/tcp_fastopen: fix data races around tfo_active_disable_stamp
  spi: cadence: Correct initialisation of runtime PM again
  scsi: target: Fix protect handling in WRITE SAME(32)
  scsi: iscsi: Fix iface sysfs attr detection
  netrom: Decrease sock refcount when sock timers expire
  KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak
  net: decnet: Fix sleeping inside in af_decnet
  net: fix uninit-value in caif_seqpkt_sendmsg
  bpftool: Check malloc return value in mount_bpffs_for_pin
  s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1]
  liquidio: Fix unintentional sign extension issue on left shift of u16
  spi: mediatek: fix fifo rx mode
  perf probe-file: Delete namelist in del_events() on the error path
  perf test bpf: Free obj_buf
  perf lzma: Close lzma stream on exit
  perf dso: Fix memory leak in dso__new_map()
  perf probe: Fix dso->nsinfo refcounting
  perf map: Fix dso->nsinfo refcounting
  nvme-pci: do not call nvme_dev_remove_admin from nvme_remove
  ipv6: fix 'disable_policy' for fwd packets
  igb: Fix position of assignment to *ring
  igb: Check if num of q_vectors is smaller than max before array access
  iavf: Fix an error handling path in 'iavf_probe()'
  e1000e: Fix an error handling path in 'e1000_probe()'
  fm10k: Fix an error handling path in 'fm10k_probe()'
  igb: Fix an error handling path in 'igb_probe()'
  ixgbe: Fix an error handling path in 'ixgbe_probe()'
  igb: Fix use-after-free error during reset
  net: ip_tunnel: fix mtu calculation for ETHER tunnel devices
  udp: annotate data races around unix_sk(sk)->gso_size
  bpftool: Properly close va_list 'ap' by va_end() on error
  ipv6: tcp: drop silly ICMPv6 packet too big messages
  tcp: annotate data races around tp->mtu_info
  dma-buf/sync_file: Don't leak fences on merge failure
  net: validate lwtstate->data before returning from skb_tunnel_info()
  net: send SYNACK packet with accepted fwmark
  net: ti: fix UAF in tlan_remove_one
  net: qcom/emac: fix UAF in emac_remove
  net: moxa: fix UAF in moxart_mac_probe
  net: bcmgenet: Ensure all TX/RX queues DMAs are disabled
  net: bridge: sync fdb to new unicast-filtering ports
  netfilter: ctnetlink: suspicious RCU usage in ctnetlink_dump_helpinfo
  net: ipv6: fix return value of ip6_skb_dst_mtu
  net: dsa: mv88e6xxx: enable .rmu_disable() on Topaz
  dm writecache: fix writing beyond end of underlying device when shrinking
  dm writecache: return the exact table values that were set
  mm: slab: fix kmem_cache_create failed when sysfs node not destroyed
  sched/fair: Fix CFS bandwidth hrtimer expiry type
  scsi: libfc: Fix array index out of bound exception
  scsi: libsas: Add LUN number check in .slave_alloc callback
  scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8
  rtc: max77686: Do not enforce (incorrect) interrupt trigger type
  kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set
  thermal/core: Correct function name thermal_zone_device_unregister()
  arm64: dts: ls208xa: remove bus-num from dspi node
  soc/tegra: fuse: Fix Tegra234-only builds
  ARM: dts: stm32: move stmmac axi config in ethernet node on stm32mp15
  ARM: dts: stm32: fix i2c node name on stm32f746 to prevent warnings
  ARM: dts: rockchip: fix supply properties in io-domains nodes
  arm64: dts: juno: Update SCPI nodes as per the YAML schema
  ARM: dts: stm32: fix timer nodes on STM32 MCU to prevent warnings
  ARM: dts: stm32: fix RCC node name on stm32f429 MCU
  ARM: dts: stm32: fix gpio-keys node on STM32 MCU boards
  rtc: mxc_v2: add missing MODULE_DEVICE_TABLE
  ARM: imx: pm-imx5: Fix references to imx5_cpu_suspend_info
  ARM: dts: imx6: phyFLEX: Fix UART hardware flow control
  ARM: dts: Hurricane 2: Fix NAND nodes names
  ARM: dts: BCM63xx: Fix NAND nodes names
  ARM: NSP: dts: fix NAND nodes names
  ARM: Cygnus: dts: fix NAND nodes names
  ARM: brcmstb: dts: fix NAND nodes names
  reset: ti-syscon: fix to_ti_syscon_reset_data macro
  arm64: dts: rockchip: Fix power-controller node names for rk3328
  ARM: dts: rockchip: Fix power-controller node names for rk3288
  ARM: dts: rockchip: Fix IOMMU nodes properties on rk322x
  ARM: dts: rockchip: Fix the timer clocks order
  arm64: dts: rockchip: fix pinctrl sleep nodename for rk3399.dtsi
  ARM: dts: rockchip: fix pinctrl sleep nodename for rk3036-kylin and rk3288
  ARM: dts: gemini: add device_type on pci
  ARM: dts: gemini: rename mdio to the right name
  ANDROID: generate_initcall_order.pl: Use two dash long options for llvm-nm
  Revert "media: subdev: disallow ioctl for saa6588/davinci"
  ANDROID: GKI: fix up crc change in ip.h
  Linux 4.19.198
  seq_file: disallow extremely large seq buffer allocations
  scsi: scsi_dh_alua: Fix signedness bug in alua_rtpg()
  net: bridge: multicast: fix PIM hello router port marking race
  MIPS: vdso: Invalid GIC access through VDSO
  mips: disable branch profiling in boot/decompress.o
  mips: always link byteswap helpers into decompressor
  scsi: be2iscsi: Fix an error handling path in beiscsi_dev_probe()
  ARM: dts: imx6q-dhcom: Add gpios pinctrl for i2c bus recovery
  ARM: dts: imx6q-dhcom: Fix ethernet plugin detection problems
  ARM: dts: imx6q-dhcom: Fix ethernet reset time properties
  ARM: dts: am437x: align ti,pindir-d0-out-d1-in property with dt-shema
  ARM: dts: am335x: align ti,pindir-d0-out-d1-in property with dt-shema
  memory: fsl_ifc: fix leak of private memory on probe failure
  memory: fsl_ifc: fix leak of IO mapping on probe failure
  reset: bail if try_module_get() fails
  ARM: dts: BCM5301X: Fixup SPI binding
  ARM: dts: r8a7779, marzen: Fix DU clock names
  arm64: dts: renesas: v3msk: Fix memory size
  rtc: fix snprintf() checking in is_rtc_hctosys()
  memory: atmel-ebi: add missing of_node_put for loop iteration
  ARM: dts: exynos: fix PWM LED max brightness on Odroid XU4
  ARM: dts: exynos: fix PWM LED max brightness on Odroid HC1
  ARM: dts: exynos: fix PWM LED max brightness on Odroid XU/XU3
  reset: a10sr: add missing of_match_table reference
  hexagon: use common DISCARDS macro
  NFSv4/pNFS: Don't call _nfs4_pnfs_v3_ds_connect multiple times
  ALSA: isa: Fix error return code in snd_cmi8330_probe()
  virtio_net: move tx vq operation under tx queue lock
  x86/fpu: Limit xstate copy size in xstateregs_set()
  PCI: iproc: Support multi-MSI only on uniprocessor kernel
  PCI: iproc: Fix multi-MSI base vector number allocation
  ubifs: Set/Clear I_LINKABLE under i_lock for whiteout inode
  nfs: fix acl memory leak of posix_acl_create()
  watchdog: aspeed: fix hardware timeout calculation
  um: fix error return code in winch_tramp()
  um: fix error return code in slip_open()
  NFSv4: Initialise connection to the server in nfs4_alloc_client()
  power: supply: rt5033_battery: Fix device tree enumeration
  PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun
  f2fs: add MODULE_SOFTDEP to ensure crc32 is included in the initramfs
  virtio_console: Assure used length from device is limited
  virtio_net: Fix error handling in virtnet_restore()
  virtio-blk: Fix memory leak among suspend/resume procedure
  ACPI: video: Add quirk for the Dell Vostro 3350
  ACPI: AMBA: Fix resource name in /proc/iomem
  pwm: tegra: Don't modify HW state in .remove callback
  power: supply: ab8500: add missing MODULE_DEVICE_TABLE
  power: supply: charger-manager: add missing MODULE_DEVICE_TABLE
  NFS: nfs_find_open_context() may only select open files
  ceph: remove bogus checks and WARN_ONs from ceph_set_page_dirty
  orangefs: fix orangefs df output.
  PCI: tegra: Add missing MODULE_DEVICE_TABLE
  x86/fpu: Return proper error codes from user access functions
  watchdog: iTCO_wdt: Account for rebooting on second timeout
  watchdog: Fix possible use-after-free by calling del_timer_sync()
  watchdog: sc520_wdt: Fix possible use-after-free in wdt_turnoff()
  watchdog: Fix possible use-after-free in wdt_startup()
  ARM: 9087/1: kprobes: test-thumb: fix for LLVM_IAS=1
  power: reset: gpio-poweroff: add missing MODULE_DEVICE_TABLE
  power: supply: max17042: Do not enforce (incorrect) interrupt trigger type
  power: supply: ab8500: Avoid NULL pointers
  pwm: spear: Don't modify HW state in .remove callback
  lib/decompress_unlz4.c: correctly handle zero-padding around initrds.
  i2c: core: Disable client irq on reboot/shutdown
  intel_th: Wait until port is in reset before programming it
  staging: rtl8723bs: fix macro value for 2.4Ghz only device
  ALSA: hda: Add IRQ check for platform_get_irq()
  backlight: lm3630a: Fix return code of .update_status() callback
  powerpc/boot: Fixup device-tree on little endian
  usb: gadget: hid: fix error return code in hid_bind()
  usb: gadget: f_hid: fix endianness issue with descriptors
  ALSA: bebob: add support for ToneWeal FW66
  Input: hideep - fix the uninitialized use in hideep_nvm_unlock()
  ASoC: soc-core: Fix the error return code in snd_soc_of_parse_audio_routing()
  gpio: pca953x: Add support for the On Semi pca9655
  selftests/powerpc: Fix "no_handler" EBB selftest
  ALSA: ppc: fix error return code in snd_pmac_probe()
  gpio: zynq: Check return value of pm_runtime_get_sync
  powerpc/ps3: Add dma_mask to ps3_dma_region
  ALSA: sb: Fix potential double-free of CSP mixer elements
  selftests: timers: rtcpie: skip test if default RTC device does not exist
  s390/sclp_vt220: fix console name to match device
  mfd: da9052/stmpe: Add and modify MODULE_DEVICE_TABLE
  scsi: qedi: Fix null ref during abort handling
  scsi: iscsi: Fix shost->max_id use
  scsi: iscsi: Fix conn use after free during resets
  scsi: iscsi: Add iscsi_cls_conn refcount helpers
  fs/jfs: Fix missing error code in lmLogInit()
  scsi: scsi_dh_alua: Check for negative result value
  tty: serial: 8250: serial_cs: Fix a memory leak in error handling path
  ALSA: ac97: fix PM reference leak in ac97_bus_remove()
  scsi: core: Cap scsi_host cmd_per_lun at can_queue
  scsi: lpfc: Fix crash when lpfc_sli4_hba_setup() fails to initialize the SGLs
  scsi: lpfc: Fix "Unexpected timeout" error in direct attach topology
  w1: ds2438: fixing bug that would always get page0
  Revert "ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro"
  misc/libmasm/module: Fix two use after free in ibmasm_init_one
  tty: serial: fsl_lpuart: fix the potential risk of division or modulo by zero
  PCI: aardvark: Fix kernel panic during PIO transfer
  PCI: aardvark: Don't rely on jiffies while holding spinlock
  tracing: Do not reference char * as a string in histograms
  scsi: core: Fix bad pointer dereference when ehandler kthread is invalid
  KVM: X86: Disable hardware breakpoints unconditionally before kvm_x86->run()
  KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled
  smackfs: restrict bytes count in smk_set_cipso()
  jfs: fix GPF in diFree
  pinctrl: mcp23s08: Fix missing unlock on error in mcp23s08_irq()
  media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K
  media: gspca/sunplus: fix zero-length control requests
  media: gspca/sq905: fix control-request direction
  media: zr364xx: fix memory leak in zr364xx_start_readpipe
  media: dtv5100: fix control-request directions
  media: subdev: disallow ioctl for saa6588/davinci
  PCI: aardvark: Fix checking for PIO Non-posted Request
  PCI: Leave Apple Thunderbolt controllers on for s2idle or standby
  dm btree remove: assign new_root only when removal succeeds
  coresight: tmc-etf: Fix global-out-of-bounds in tmc_update_etf_buffer()
  ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe
  tracing: Resize tgid_map to pid_max, not PID_MAX_DEFAULT
  tracing: Simplify & fix saved_tgids logic
  seq_buf: Fix overflow in seq_buf_putmem_hex()
  power: supply: ab8500: Fix an old bug
  ipmi/watchdog: Stop watchdog timer when the current action is 'none'
  qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
  ASoC: tegra: Set driver_name=tegra for all machine drivers
  clocksource/arm_arch_timer: Improve Allwinner A64 timer workaround
  cpu/hotplug: Cure the cpusets trainwreck
  ata: ahci_sunxi: Disable DIPM
  mmc: core: Allow UHS-I voltage switch for SDSC cards if supported
  mmc: core: clear flags before allowing to retune
  mmc: sdhci: Fix warning message when accessing RPMB in HS400 mode
  drm/msm/mdp4: Fix modifier support enabling
  pinctrl/amd: Add device HID for new AMD GPIO controller
  drm/amd/display: fix incorrrect valid irq check
  drm/radeon: Add the missed drm_gem_object_put() in radeon_user_framebuffer_create()
  usb: gadget: f_fs: Fix setting of device and driver data cross-references
  powerpc/barrier: Avoid collision with clang's __lwsync macro
  fuse: reject internal errno
  serial: mvebu-uart: fix calculation of clock divisor
  serial: mvebu-uart: clarify the baud rate derivation
  bdi: Do not use freezable workqueue
  fscrypt: don't ignore minor_hash when hash is 0
  MIPS: set mips32r5 for virt extensions
  sctp: add size validation when walking chunks
  sctp: validate from_addr_param return
  Bluetooth: btusb: fix bt fiwmare downloading failure issue for qca btsoc.
  Bluetooth: Shutdown controller after workqueues are flushed or cancelled
  Bluetooth: Fix the HCI to MGMT status conversion table
  RDMA/cma: Fix rdma_resolve_route() memory leak
  net: ip: avoid OOM kills with large UDP sends over loopback
  media, bpf: Do not copy more entries than user space requested
  wireless: wext-spy: Fix out-of-bounds warning
  sfc: error code if SRIOV cannot be disabled
  sfc: avoid double pci_remove of VFs
  iwlwifi: pcie: free IML DMA memory allocation
  iwlwifi: mvm: don't change band on bound PHY contexts
  RDMA/rxe: Don't overwrite errno from ib_umem_get()
  vsock: notify server to shutdown when client has pending signal
  atm: nicstar: register the interrupt handler in the right place
  atm: nicstar: use 'dma_free_coherent' instead of 'kfree'
  MIPS: add PMD table accounting into MIPS'pmd_alloc_one
  rtl8xxxu: Fix device info for RTL8192EU devices
  net: fix mistake path for netdev_features_strings
  cw1200: add missing MODULE_DEVICE_TABLE
  wl1251: Fix possible buffer overflow in wl1251_cmd_scan
  wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP
  xfrm: Fix error reporting in xfrm_state_construct.
  selinux: use __GFP_NOWARN with GFP_NOWAIT in the AVC
  fjes: check return value after calling platform_get_resource()
  net: micrel: check return value after calling platform_get_resource()
  net: mvpp2: check return value after calling platform_get_resource()
  net: bcmgenet: check return value after calling platform_get_resource()
  virtio_net: Remove BUG() to avoid machine dead
  ice: set the value of global config lock timeout longer
  pinctrl: mcp23s08: fix race condition in irq handler
  dm space maps: don't reset space map allocation cursor when committing
  RDMA/cxgb4: Fix missing error code in create_qp()
  ipv6: use prandom_u32() for ID generation
  clk: tegra: Ensure that PLLU configuration is applied properly
  clk: renesas: r8a77995: Add ZA2 clock
  e100: handle eeprom as little endian
  udf: Fix NULL pointer dereference in udf_symlink function
  drm/virtio: Fix double free on probe failure
  reiserfs: add check for invalid 1st journal block
  net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT
  atm: nicstar: Fix possible use-after-free in nicstar_cleanup()
  mISDN: fix possible use-after-free in HFC_cleanup()
  atm: iphase: fix possible use-after-free in ia_module_exit()
  hugetlb: clear huge pte during flush function on mips platform
  drm/amd/display: fix use_max_lb flag for 420 pixel formats
  net: pch_gbe: Use proper accessors to BE data in pch_ptp_match()
  drm/amd/amdgpu/sriov disable all ip hw status by default
  drm/zte: Don't select DRM_KMS_FB_HELPER
  drm/mxsfb: Don't select DRM_KMS_FB_HELPER
  mmc: vub3000: fix control-request direction
  mmc: block: Disable CMDQ on the ioctl path
  perf llvm: Return -ENOMEM when asprintf() fails
  selftests/vm/pkeys: fix alloc_random_pkey() to make it really, really random
  mm/huge_memory.c: don't discard hugepage if other processes are mapping it
  vfio/pci: Handle concurrent vma faults
  arm64: dts: marvell: armada-37xx: Fix reg for standard variant of UART
  serial: mvebu-uart: correctly calculate minimal possible baudrate
  powerpc: Offline CPU in stop_this_cpu()
  leds: ktd2692: Fix an error handling path
  leds: as3645a: Fix error return code in as3645a_parse_node()
  configfs: fix memleak in configfs_release_bin_file
  ASoC: atmel-i2s: Fix usage of capture and playback at the same time
  extcon: max8997: Add missing modalias string
  extcon: sm5502: Drop invalid register write in sm5502_reg_data
  phy: ti: dm816x: Fix the error handling path in 'dm816x_usb_phy_probe()
  scsi: mpt3sas: Fix error return value in _scsih_expander_add()
  mtd: rawnand: marvell: add missing clk_disable_unprepare() on error in marvell_nfc_resume()
  of: Fix truncation of memory sizes on 32-bit platforms
  ASoC: cs42l42: Correct definition of CS42L42_ADC_PDN_MASK
  iio: prox: isl29501: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  serial: 8250: Actually allow UPF_MAGIC_MULTIPLIER baud rates
  staging: mt7621-dts: fix pci address for PCI memory range
  staging: gdm724x: check for overflow in gdm_lte_netif_rx()
  staging: gdm724x: check for buffer overflow in gdm_lte_multi_sdu_pkt()
  iio: adc: ti-ads8688: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()
  iio: adc: mxs-lradc: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: adc: hx711: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  eeprom: idt_89hpesx: Restore printing the unsupported fwnode name
  eeprom: idt_89hpesx: Put fwnode in matching case during ->probe()
  s390: appldata depends on PROC_SYSCTL
  visorbus: fix error return code in visorchipset_init()
  fsi/sbefifo: Fix reset timeout
  fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
  fsi: scom: Reset the FSI2PIB engine for any error
  fsi: core: Fix return of error values on failures
  scsi: FlashPoint: Rename si_flags field
  tty: nozomi: Fix the error handling path of 'nozomi_card_init()'
  char: pcmcia: error out if 'num_bytes_read' is greater than 4 in set_protocol()
  Input: hil_kbd - fix error return code in hil_dev_connect()
  ASoC: rsnd: tidyup loop on rsnd_adg_clk_query()
  ASoC: hisilicon: fix missing clk_disable_unprepare() on error in hi6210_i2s_startup()
  iio: potentiostat: lmp91000: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()
  iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: light: tcs3414: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: hid: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
  iio: adis_buffer: do not return ints in irq handlers
  mwifiex: re-fix for unaligned accesses
  tty: nozomi: Fix a resource leak in an error handling function
  RDMA/mlx5: Don't access NULL-cleared mpi pointer
  net: sched: fix warning in tcindex_alloc_perfect_hash
  net: lwtunnel: handle MTU calculation in forwading
  writeback: fix obtain a reference to a freeing memcg css
  Bluetooth: Fix handling of HCI_LE_Advertising_Set_Terminated event
  Bluetooth: mgmt: Fix slab-out-of-bounds in tlv_data_is_valid
  ipv6: fix out-of-bound access in ip6_parse_tlv()
  ibmvnic: free tx_pool if tso_pool alloc fails
  Revert "ibmvnic: remove duplicate napi_schedule call in open function"
  i40e: Fix autoneg disabling for non-10GBaseT links
  i40e: Fix error handling in i40e_vsi_open
  bpf: Do not change gso_size during bpf_skb_change_proto()
  ipv6: exthdrs: do not blindly use init_net
  net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  mac80211: remove iwlwifi specific workaround NDPs of null_response
  ieee802154: hwsim: avoid possible crash in hwsim_del_edge_nl()
  ieee802154: hwsim: Fix memory leak in hwsim_add_one
  net/ipv4: swap flow ports when validating source
  vxlan: add missing rcu_read_lock() in neigh_reduce()
  pkt_sched: sch_qfq: fix qfq_change_class() error path
  net: ethernet: ezchip: fix error handling
  net: ethernet: ezchip: fix UAF in nps_enet_remove
  net: ethernet: aeroflex: fix UAF in greth_of_remove
  samples/bpf: Fix the error return code of xdp_redirect's main()
  RDMA/rxe: Fix qp reference counting for atomic ops
  netfilter: nft_tproxy: restrict support to TCP and UDP transport protocols
  netfilter: nft_osf: check for TCP packet before further processing
  netfilter: nft_exthdr: check for IPv6 packet before further processing
  RDMA/mlx5: Don't add slave port to unaffiliated list
  netlabel: Fix memory leak in netlbl_mgmt_add_common
  ath10k: Fix an error code in ath10k_add_interface()
  brcmsmac: mac80211_if: Fix a resource leak in an error handling path
  brcmfmac: correctly report average RSSI in station info
  brcmfmac: fix setting of station info chains bitmask
  ssb: Fix error return code in ssb_bus_scan()
  wcn36xx: Move hal_buf allocation to devm_kmalloc in probe
  ieee802154: hwsim: Fix possible memory leak in hwsim_subscribe_all_others
  wireless: carl9170: fix LEDS build errors & warnings
  tools/bpftool: Fix error return code in do_batch()
  drm: qxl: ensure surf.data is ininitialized
  RDMA/rxe: Fix failure during driver load
  ehea: fix error return code in ehea_restart_qps()
  drm/rockchip: cdn-dp-core: add missing clk_disable_unprepare() on error in cdn_dp_grf_write()
  net: pch_gbe: Propagate error from devm_gpio_request_one()
  net: mvpp2: Put fwnode in error case during ->probe()
  ocfs2: fix snprintf() checking
  blk-wbt: make sure throttle is enabled properly
  blk-wbt: introduce a new disable state to prevent false positive by rwb_enabled()
  ACPI: sysfs: Fix a buffer overrun problem with description_show()
  crypto: nx - Fix RCU warning in nx842_OF_upd_status
  spi: spi-sun6i: Fix chipselect/clock bug
  btrfs: clear log tree recovering status if starting transaction fails
  hwmon: (max31790) Fix fan speed reporting for fan7..12
  hwmon: (max31722) Remove non-standard ACPI device IDs
  media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
  mmc: usdhi6rol0: fix error return code in usdhi6_probe()
  media: siano: Fix out-of-bounds warnings in smscore_load_firmware_family2()
  media: gspca/gl860: fix zero-length control requests
  media: tc358743: Fix error return code in tc358743_probe_of()
  media: exynos4-is: Fix a use after free in isp_video_release
  pata_ep93xx: fix deferred probing
  media: rc: i2c: Fix an error message
  crypto: ccp - Fix a resource leak in an error handling path
  evm: fix writing <securityfs>/evm overflow
  pata_octeon_cf: avoid WARN_ON() in ata_host_activate()
  media: I2C: change 'RST' to "RSET" to fix multiple build errors
  pata_rb532_cf: fix deferred probing
  sata_highbank: fix deferred probing
  crypto: ux500 - Fix error return code in hash_hw_final()
  crypto: ixp4xx - dma_unmap the correct address
  media: s5p_cec: decrement usage count if disabled
  ia64: mca_drv: fix incorrect array size calculation
  HID: wacom: Correct base usage for capacitive ExpressKey status bits
  ACPI: tables: Add custom DSDT file as makefile prerequisite
  clocksource: Retry clock read if long delays detected
  platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard()
  ACPI: bus: Call kobject_put() in acpi_init() error path
  ACPICA: Fix memory leak caused by _CID repair function
  fs: dlm: fix memory leak when fenced
  random32: Fix implicit truncation warning in prandom_seed_state()
  fs: dlm: cancel work sync othercon
  block_dump: remove block_dump feature in mark_inode_dirty()
  ACPI: EC: Make more Asus laptops use ECDT _GPE
  lib: vsprintf: Fix handling of number field widths in vsscanf
  hv_utils: Fix passing zero to 'PTR_ERR' warning
  ACPI: processor idle: Fix up C-state latency if not ordered
  EDAC/ti: Add missing MODULE_DEVICE_TABLE
  HID: do not use down_interruptible() when unbinding devices
  regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
  btrfs: disable build on platforms having page size 256K
  btrfs: abort transaction if we fail to update the delayed inode
  btrfs: fix error handling in __btrfs_update_delayed_inode
  media: imx-csi: Skip first few frames from a BT.656 source
  media: siano: fix device register error path
  media: dvb_net: avoid speculation from net slot
  crypto: shash - avoid comparing pointers to exported functions under CFI
  mmc: via-sdmmc: add a check against NULL pointer dereference
  media: dvd_usb: memory leak in cinergyt2_fe_attach
  media: st-hva: Fix potential NULL pointer dereferences
  media: bt8xx: Fix a missing check bug in bt878_probe
  media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release
  media: em28xx: Fix possible memory leak of em28xx struct
  sched/fair: Fix ascii art by relpacing tabs
  crypto: qat - remove unused macro in FW loader
  crypto: qat - check return code of qat_hal_rd_rel_reg()
  media: pvrusb2: fix warning in pvr2_i2c_core_done
  media: cobalt: fix race condition in setting HPD
  media: cpia2: fix memory leak in cpia2_usb_probe
  crypto: nx - add missing MODULE_DEVICE_TABLE
  regulator: uniphier: Add missing MODULE_DEVICE_TABLE
  spi: omap-100k: Fix the length judgment problem
  spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages()
  spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf'
  spi: Make of_register_spi_device also set the fwnode
  fuse: check connected before queueing on fpq->io
  evm: Refuse EVM_ALLOW_METADATA_WRITES only if an HMAC key is loaded
  evm: Execute evm_inode_init_security() only when an HMAC key is loaded
  powerpc/stacktrace: Fix spurious "stale" traces in raise_backtrace_ipi()
  seq_buf: Make trace_seq_putmem_hex() support data longer than 8
  tracepoint: Add tracepoint_probe_register_may_exist() for BPF tracing
  tracing/histograms: Fix parsing of "sym-offset" modifier
  rsi: fix AP mode with WPA failure due to encrypted EAPOL
  rsi: Assign beacon rate settings to the correct rate_info descriptor field
  ssb: sdio: Don't overwrite const buffer if block_write fails
  ath9k: Fix kernel NULL pointer dereference during ath_reset_internal()
  serial_cs: remove wrong GLOBETROTTER.cis entry
  serial_cs: Add Option International GSM-Ready 56K/ISDN modem
  serial: sh-sci: Stop dmaengine transfer in sci_stop_tx()
  iio: ltr501: ltr501_read_ps(): add missing endianness conversion
  iio: ltr501: ltr559: fix initialization of LTR501_ALS_CONTR
  iio: ltr501: mark register holding upper 8 bits of ALS_DATA{0,1} and PS_DATA as volatile, too
  iio: light: tcs3472: do not free unallocated IRQ
  rtc: stm32: Fix unbalanced clk_disable_unprepare() on probe error path
  s390/cio: dont call css_wait_for_slow_path() inside a lock
  SUNRPC: Should wake up the privileged task firstly.
  SUNRPC: Fix the batch tasks count wraparound.
  can: peak_pciefd: pucan_handle_status(): fix a potential starvation issue in TX path
  can: gw: synchronize rcu operations before removing gw job entry
  can: bcm: delay release of struct bcm_op after synchronize_rcu()
  ext4: use ext4_grp_locked_error in mb_find_extent
  ext4: fix avefreec in find_group_orlov
  ext4: remove check for zero nr_to_scan in ext4_es_scan()
  ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit
  ext4: return error code when ext4_fill_flex_info() fails
  ext4: fix kernel infoleak via ext4_extent_header
  ext4: cleanup in-core orphan list if ext4_truncate() failed to get a transaction handle
  btrfs: clear defrag status of a root if starting transaction fails
  btrfs: send: fix invalid path for unlink operations after parent orphanization
  ARM: dts: at91: sama5d4: fix pinctrl muxing
  arm_pmu: Fix write counter incorrect in ARMv7 big-endian mode
  Input: joydev - prevent use of not validated data in JSIOCSBTNMAP ioctl
  iov_iter_fault_in_readable() should do nothing in xarray case
  ntfs: fix validity check for file name attribute
  xhci: solve a double free problem while doing s4
  usb: typec: Add the missed altmode_id_remove() in typec_register_altmode()
  usb: dwc3: Fix debugfs creation flow
  USB: cdc-acm: blacklist Heimann USB Appset device
  usb: gadget: eem: fix echo command packet response issue
  net: can: ems_usb: fix use-after-free in ems_usb_disconnect()
  Input: usbtouchscreen - fix control-request directions
  media: dvb-usb: fix wrong definition
  ALSA: usb-audio: Fix OOB access at proc output
  ALSA: usb-audio: fix rate on Ozone Z90 USB headset
  scsi: core: Retry I/O for Notify (Enable Spinup) Required error
  Revert "clocksource/drivers/timer-ti-dm: Handle dra7 timer wrap errata i940"
  Linux 4.19.197
  clocksource/drivers/timer-ti-dm: Handle dra7 timer wrap errata i940
  clocksource/drivers/timer-ti-dm: Prepare to handle dra7 timer wrap issue
  clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support
  ARM: OMAP: replace setup_irq() by request_irq()
  KVM: SVM: Call SEV Guest Decommission if ASID binding fails
  xen/events: reset active flag for lateeoi events later
  kthread: prevent deadlock when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync()
  kthread_worker: split code for canceling the delayed work timer
  ARM: dts: imx6qdl-sabresd: Remove incorrect power supply assignment
  KVM: SVM: Periodically schedule when unregistering regions on destroy
  ext4: eliminate bogus error in ext4_data_block_valid_rcu()
  drm/nouveau: fix dma_address check for CPU/GPU sync
  scsi: sr: Return appropriate error code when disk is ejected
  mm, futex: fix shared futex pgoff on shmem huge page
  mm/thp: another PVMW_SYNC fix in page_vma_mapped_walk()
  mm/thp: fix page_vma_mapped_walk() if THP mapped by ptes
  mm: page_vma_mapped_walk(): get vma_address_end() earlier
  mm: page_vma_mapped_walk(): use goto instead of while (1)
  mm: page_vma_mapped_walk(): add a level of indentation
  mm: page_vma_mapped_walk(): crossing page table boundary
  mm: page_vma_mapped_walk(): prettify PVMW_MIGRATION block
  mm: page_vma_mapped_walk(): use pmde for *pvmw->pmd
  mm: page_vma_mapped_walk(): settle PageHuge on entry
  mm: page_vma_mapped_walk(): use page for pvmw->page
  mm: thp: replace DEBUG_VM BUG with VM_WARN when unmap fails for split
  mm/thp: unmap_mapping_page() to fix THP truncate_cleanup_page()
  mm/thp: fix page_address_in_vma() on file THP tails
  mm/thp: fix vma_address() if virtual address below file offset
  mm/thp: try_to_unmap() use TTU_SYNC for safe splitting
  mm/thp: make is_huge_zero_pmd() safe and quicker
  mm/thp: fix __split_huge_pmd_locked() on shmem migration entry
  mm/rmap: use page_not_mapped in try_to_unmap()
  mm/rmap: remove unneeded semicolon in page_not_mapped()
  mm: add VM_WARN_ON_ONCE_PAGE() macro

Change-Id: Ia9b845672bf98427007fcdb455a467e602cfcd29
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>

Conflicts:
	drivers/staging/android/ion/ion.c
	drivers/usb/dwc3/core.c
	drivers/usb/gadget/function/f_fs.c
	kernel/cpu.c
	security/selinux/avc.c
2022-02-26 15:38:42 +05:30

606 lines
15 KiB
C

/*
* Synchronous Cryptographic Hash operations.
*
* Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#include <crypto/scatterwalk.h>
#include <crypto/internal/hash.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/seq_file.h>
#include <linux/cryptouser.h>
#include <net/netlink.h>
#include <linux/compiler.h>
#include "internal.h"
static const struct crypto_type crypto_shash_type;
static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
return -ENOSYS;
}
/*
* Check whether an shash algorithm has a setkey function.
*
* For CFI compatibility, this must not be an inline function. This is because
* when CFI is enabled, modules won't get the same address for shash_no_setkey
* (if it were exported, which inlining would require) as the core kernel will.
*/
bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
{
return alg->setkey != shash_no_setkey;
}
EXPORT_SYMBOL_GPL(crypto_shash_alg_has_setkey);
static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
unsigned long absize;
u8 *buffer, *alignbuffer;
int err;
absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
buffer = kmalloc(absize, GFP_ATOMIC);
if (!buffer)
return -ENOMEM;
alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
memcpy(alignbuffer, key, keylen);
err = shash->setkey(tfm, alignbuffer, keylen);
kzfree(buffer);
return err;
}
static void shash_set_needkey(struct crypto_shash *tfm, struct shash_alg *alg)
{
if (crypto_shash_alg_has_setkey(alg) &&
!(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
crypto_shash_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
}
int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
int err;
if ((unsigned long)key & alignmask)
err = shash_setkey_unaligned(tfm, key, keylen);
else
err = shash->setkey(tfm, key, keylen);
if (unlikely(err)) {
shash_set_needkey(tfm, shash);
return err;
}
crypto_shash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
return 0;
}
EXPORT_SYMBOL_GPL(crypto_shash_setkey);
static int shash_update_unaligned(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
struct crypto_shash *tfm = desc->tfm;
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
unsigned int unaligned_len = alignmask + 1 -
((unsigned long)data & alignmask);
/*
* We cannot count on __aligned() working for large values:
* https://patchwork.kernel.org/patch/9507697/
*/
u8 ubuf[MAX_ALGAPI_ALIGNMASK * 2];
u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
int err;
if (WARN_ON(buf + unaligned_len > ubuf + sizeof(ubuf)))
return -EINVAL;
if (unaligned_len > len)
unaligned_len = len;
memcpy(buf, data, unaligned_len);
err = shash->update(desc, buf, unaligned_len);
memset(buf, 0, unaligned_len);
return err ?:
shash->update(desc, data + unaligned_len, len - unaligned_len);
}
int crypto_shash_update(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
struct crypto_shash *tfm = desc->tfm;
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
if ((unsigned long)data & alignmask)
return shash_update_unaligned(desc, data, len);
return shash->update(desc, data, len);
}
EXPORT_SYMBOL_GPL(crypto_shash_update);
static int shash_final_unaligned(struct shash_desc *desc, u8 *out)
{
struct crypto_shash *tfm = desc->tfm;
unsigned long alignmask = crypto_shash_alignmask(tfm);
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned int ds = crypto_shash_digestsize(tfm);
/*
* We cannot count on __aligned() working for large values:
* https://patchwork.kernel.org/patch/9507697/
*/
u8 ubuf[MAX_ALGAPI_ALIGNMASK + HASH_MAX_DIGESTSIZE];
u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
int err;
if (WARN_ON(buf + ds > ubuf + sizeof(ubuf)))
return -EINVAL;
err = shash->final(desc, buf);
if (err)
goto out;
memcpy(out, buf, ds);
out:
memset(buf, 0, ds);
return err;
}
int crypto_shash_final(struct shash_desc *desc, u8 *out)
{
struct crypto_shash *tfm = desc->tfm;
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
if ((unsigned long)out & alignmask)
return shash_final_unaligned(desc, out);
return shash->final(desc, out);
}
EXPORT_SYMBOL_GPL(crypto_shash_final);
static int shash_finup_unaligned(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
return crypto_shash_update(desc, data, len) ?:
crypto_shash_final(desc, out);
}
int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
struct crypto_shash *tfm = desc->tfm;
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
if (((unsigned long)data | (unsigned long)out) & alignmask)
return shash_finup_unaligned(desc, data, len, out);
return shash->finup(desc, data, len, out);
}
EXPORT_SYMBOL_GPL(crypto_shash_finup);
static int shash_digest_unaligned(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
return crypto_shash_init(desc) ?:
crypto_shash_finup(desc, data, len, out);
}
int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
struct crypto_shash *tfm = desc->tfm;
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);
if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
return -ENOKEY;
if (((unsigned long)data | (unsigned long)out) & alignmask)
return shash_digest_unaligned(desc, data, len, out);
return shash->digest(desc, data, len, out);
}
EXPORT_SYMBOL_GPL(crypto_shash_digest);
static int shash_default_export(struct shash_desc *desc, void *out)
{
memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm));
return 0;
}
static int shash_default_import(struct shash_desc *desc, const void *in)
{
memcpy(shash_desc_ctx(desc), in, crypto_shash_descsize(desc->tfm));
return 0;
}
static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key,
unsigned int keylen)
{
struct crypto_shash **ctx = crypto_ahash_ctx(tfm);
return crypto_shash_setkey(*ctx, key, keylen);
}
static int shash_async_init(struct ahash_request *req)
{
struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct shash_desc *desc = ahash_request_ctx(req);
desc->tfm = *ctx;
desc->flags = req->base.flags;
return crypto_shash_init(desc);
}
int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc)
{
struct crypto_hash_walk walk;
int nbytes;
for (nbytes = crypto_hash_walk_first(req, &walk); nbytes > 0;
nbytes = crypto_hash_walk_done(&walk, nbytes))
nbytes = crypto_shash_update(desc, walk.data, nbytes);
return nbytes;
}
EXPORT_SYMBOL_GPL(shash_ahash_update);
static int shash_async_update(struct ahash_request *req)
{
return shash_ahash_update(req, ahash_request_ctx(req));
}
static int shash_async_final(struct ahash_request *req)
{
return crypto_shash_final(ahash_request_ctx(req), req->result);
}
int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc)
{
struct crypto_hash_walk walk;
int nbytes;
nbytes = crypto_hash_walk_first(req, &walk);
if (!nbytes)
return crypto_shash_final(desc, req->result);
do {
nbytes = crypto_hash_walk_last(&walk) ?
crypto_shash_finup(desc, walk.data, nbytes,
req->result) :
crypto_shash_update(desc, walk.data, nbytes);
nbytes = crypto_hash_walk_done(&walk, nbytes);
} while (nbytes > 0);
return nbytes;
}
EXPORT_SYMBOL_GPL(shash_ahash_finup);
static int shash_async_finup(struct ahash_request *req)
{
struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct shash_desc *desc = ahash_request_ctx(req);
desc->tfm = *ctx;
desc->flags = req->base.flags;
return shash_ahash_finup(req, desc);
}
int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
{
unsigned int nbytes = req->nbytes;
struct scatterlist *sg;
unsigned int offset;
int err;
if (nbytes &&
(sg = req->src, offset = sg->offset,
nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset))) {
void *data;
data = kmap_atomic(sg_page(sg));
err = crypto_shash_digest(desc, data + offset, nbytes,
req->result);
kunmap_atomic(data);
crypto_yield(desc->flags);
} else
err = crypto_shash_init(desc) ?:
shash_ahash_finup(req, desc);
return err;
}
EXPORT_SYMBOL_GPL(shash_ahash_digest);
static int shash_async_digest(struct ahash_request *req)
{
struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct shash_desc *desc = ahash_request_ctx(req);
desc->tfm = *ctx;
desc->flags = req->base.flags;
return shash_ahash_digest(req, desc);
}
static int shash_async_export(struct ahash_request *req, void *out)
{
return crypto_shash_export(ahash_request_ctx(req), out);
}
static int shash_async_import(struct ahash_request *req, const void *in)
{
struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct shash_desc *desc = ahash_request_ctx(req);
desc->tfm = *ctx;
desc->flags = req->base.flags;
return crypto_shash_import(desc, in);
}
static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
{
struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
crypto_free_shash(*ctx);
}
int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
{
struct crypto_alg *calg = tfm->__crt_alg;
struct shash_alg *alg = __crypto_shash_alg(calg);
struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
struct crypto_shash *shash;
if (!crypto_mod_get(calg))
return -EAGAIN;
shash = crypto_create_tfm(calg, &crypto_shash_type);
if (IS_ERR(shash)) {
crypto_mod_put(calg);
return PTR_ERR(shash);
}
*ctx = shash;
tfm->exit = crypto_exit_shash_ops_async;
crt->init = shash_async_init;
crt->update = shash_async_update;
crt->final = shash_async_final;
crt->finup = shash_async_finup;
crt->digest = shash_async_digest;
if (crypto_shash_alg_has_setkey(alg))
crt->setkey = shash_async_setkey;
crypto_ahash_set_flags(crt, crypto_shash_get_flags(shash) &
CRYPTO_TFM_NEED_KEY);
if (alg->export)
crt->export = shash_async_export;
if (alg->import)
crt->import = shash_async_import;
crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
return 0;
}
static int crypto_shash_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_shash *hash = __crypto_shash_cast(tfm);
struct shash_alg *alg = crypto_shash_alg(hash);
hash->descsize = alg->descsize;
shash_set_needkey(hash, alg);
return 0;
}
#ifdef CONFIG_NET
static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
{
struct crypto_report_hash rhash;
struct shash_alg *salg = __crypto_shash_alg(alg);
strncpy(rhash.type, "shash", sizeof(rhash.type));
rhash.blocksize = alg->cra_blocksize;
rhash.digestsize = salg->digestsize;
if (nla_put(skb, CRYPTOCFGA_REPORT_HASH,
sizeof(struct crypto_report_hash), &rhash))
goto nla_put_failure;
return 0;
nla_put_failure:
return -EMSGSIZE;
}
#else
static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
{
return -ENOSYS;
}
#endif
static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
__maybe_unused;
static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
{
struct shash_alg *salg = __crypto_shash_alg(alg);
seq_printf(m, "type : shash\n");
seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
seq_printf(m, "digestsize : %u\n", salg->digestsize);
}
static const struct crypto_type crypto_shash_type = {
.extsize = crypto_alg_extsize,
.init_tfm = crypto_shash_init_tfm,
#ifdef CONFIG_PROC_FS
.show = crypto_shash_show,
#endif
.report = crypto_shash_report,
.maskclear = ~CRYPTO_ALG_TYPE_MASK,
.maskset = CRYPTO_ALG_TYPE_MASK,
.type = CRYPTO_ALG_TYPE_SHASH,
.tfmsize = offsetof(struct crypto_shash, base),
};
struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
u32 mask)
{
return crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask);
}
EXPORT_SYMBOL_GPL(crypto_alloc_shash);
static int shash_prepare_alg(struct shash_alg *alg)
{
struct crypto_alg *base = &alg->base;
if (alg->digestsize > HASH_MAX_DIGESTSIZE ||
alg->descsize > HASH_MAX_DESCSIZE ||
alg->statesize > HASH_MAX_STATESIZE)
return -EINVAL;
base->cra_type = &crypto_shash_type;
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
if (!alg->finup)
alg->finup = shash_finup_unaligned;
if (!alg->digest)
alg->digest = shash_digest_unaligned;
if (!alg->export) {
alg->export = shash_default_export;
alg->import = shash_default_import;
alg->statesize = alg->descsize;
}
if (!alg->setkey)
alg->setkey = shash_no_setkey;
return 0;
}
int crypto_register_shash(struct shash_alg *alg)
{
struct crypto_alg *base = &alg->base;
int err;
err = shash_prepare_alg(alg);
if (err)
return err;
return crypto_register_alg(base);
}
EXPORT_SYMBOL_GPL(crypto_register_shash);
int crypto_unregister_shash(struct shash_alg *alg)
{
return crypto_unregister_alg(&alg->base);
}
EXPORT_SYMBOL_GPL(crypto_unregister_shash);
int crypto_register_shashes(struct shash_alg *algs, int count)
{
int i, ret;
for (i = 0; i < count; i++) {
ret = crypto_register_shash(&algs[i]);
if (ret)
goto err;
}
return 0;
err:
for (--i; i >= 0; --i)
crypto_unregister_shash(&algs[i]);
return ret;
}
EXPORT_SYMBOL_GPL(crypto_register_shashes);
int crypto_unregister_shashes(struct shash_alg *algs, int count)
{
int i, ret;
for (i = count - 1; i >= 0; --i) {
ret = crypto_unregister_shash(&algs[i]);
if (ret)
pr_err("Failed to unregister %s %s: %d\n",
algs[i].base.cra_driver_name,
algs[i].base.cra_name, ret);
}
return 0;
}
EXPORT_SYMBOL_GPL(crypto_unregister_shashes);
int shash_register_instance(struct crypto_template *tmpl,
struct shash_instance *inst)
{
int err;
err = shash_prepare_alg(&inst->alg);
if (err)
return err;
return crypto_register_instance(tmpl, shash_crypto_instance(inst));
}
EXPORT_SYMBOL_GPL(shash_register_instance);
void shash_free_instance(struct crypto_instance *inst)
{
crypto_drop_spawn(crypto_instance_ctx(inst));
kfree(shash_instance(inst));
}
EXPORT_SYMBOL_GPL(shash_free_instance);
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
struct shash_alg *alg,
struct crypto_instance *inst)
{
return crypto_init_spawn2(&spawn->base, &alg->base, inst,
&crypto_shash_type);
}
EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
{
struct crypto_alg *alg;
alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask);
return IS_ERR(alg) ? ERR_CAST(alg) :
container_of(alg, struct shash_alg, base);
}
EXPORT_SYMBOL_GPL(shash_attr_alg);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Synchronous cryptographic hash type");