stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Corentin Labbe <clabbe.montjoie@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH 5.4 038/102] crypto: sun4i-ss - fix big endian issues
Date: Fri, 24 Jan 2020 10:30:39 +0100	[thread overview]
Message-ID: <20200124092812.022914114@linuxfoundation.org> (raw)
In-Reply-To: <20200124092806.004582306@linuxfoundation.org>

From: Corentin Labbe <clabbe.montjoie@gmail.com>

commit d1d787bcebfe122a5bd443ae565696661e2e9656 upstream.

When testing BigEndian kernel, the sun4i-ss was failling all crypto
tests.
This patch fix endian issues with it.

Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/crypto/sunxi-ss/sun4i-ss-hash.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
@@ -175,7 +175,7 @@ static int sun4i_hash(struct ahash_reque
 	 */
 	unsigned int i = 0, end, fill, min_fill, nwait, nbw = 0, j = 0, todo;
 	unsigned int in_i = 0;
-	u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, wb = 0, v, ivmode = 0;
+	u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, v, ivmode = 0;
 	struct sun4i_req_ctx *op = ahash_request_ctx(areq);
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
 	struct sun4i_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm);
@@ -184,6 +184,7 @@ static int sun4i_hash(struct ahash_reque
 	struct sg_mapping_iter mi;
 	int in_r, err = 0;
 	size_t copied = 0;
+	__le32 wb = 0;
 
 	dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x",
 		__func__, crypto_tfm_alg_name(areq->base.tfm),
@@ -395,7 +396,7 @@ hash_final:
 
 		nbw = op->len - 4 * nwait;
 		if (nbw) {
-			wb = *(u32 *)(op->buf + nwait * 4);
+			wb = cpu_to_le32(*(u32 *)(op->buf + nwait * 4));
 			wb &= GENMASK((nbw * 8) - 1, 0);
 
 			op->byte_count += nbw;
@@ -404,7 +405,7 @@ hash_final:
 
 	/* write the remaining bytes of the nbw buffer */
 	wb |= ((1 << 7) << (nbw * 8));
-	bf[j++] = wb;
+	bf[j++] = le32_to_cpu(wb);
 
 	/*
 	 * number of space to pad to obtain 64o minus 8(size) minus 4 (final 1)
@@ -423,13 +424,13 @@ hash_final:
 
 	/* write the length of data */
 	if (op->mode == SS_OP_SHA1) {
-		__be64 bits = cpu_to_be64(op->byte_count << 3);
-		bf[j++] = lower_32_bits(bits);
-		bf[j++] = upper_32_bits(bits);
+		__be64 *bits = (__be64 *)&bf[j];
+		*bits = cpu_to_be64(op->byte_count << 3);
+		j += 2;
 	} else {
-		__le64 bits = op->byte_count << 3;
-		bf[j++] = lower_32_bits(bits);
-		bf[j++] = upper_32_bits(bits);
+		__le64 *bits = (__le64 *)&bf[j];
+		*bits = cpu_to_le64(op->byte_count << 3);
+		j += 2;
 	}
 	writesl(ss->base + SS_RXFIFO, bf, j);
 
@@ -471,7 +472,7 @@ hash_final:
 		}
 	} else {
 		for (i = 0; i < 4; i++) {
-			v = readl(ss->base + SS_MD0 + i * 4);
+			v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4));
 			memcpy(areq->result + i * 4, &v, 4);
 		}
 	}



  parent reply	other threads:[~2020-01-24  9:39 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  9:30 [PATCH 5.4 000/102] 5.4.15-stable review Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 001/102] drm/i915: Fix pid leak with banned clients Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 002/102] libbpf: Fix compatibility for kernels without need_wakeup Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 003/102] libbpf: Fix memory leak/double free issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 004/102] libbpf: Fix potential overflow issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 005/102] libbpf: Fix another potential overflow issue in bpf_prog_linfo Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 006/102] libbpf: Make btf__resolve_size logic always check size error condition Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 007/102] libbpf: Fix call relocation offset calculation bug Greg Kroah-Hartman
2020-01-24 13:43   ` Naresh Kamboju
2020-01-24 15:18     ` Sasha Levin
2020-01-24  9:30 ` [PATCH 5.4 008/102] bpf: Force .BTF section start to zero when dumping from vmlinux Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 009/102] samples: bpf: update map definition to new syntax BTF-defined map Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 010/102] samples/bpf: Fix broken xdp_rxq_info due to map order assumptions Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 011/102] ARM: dts: logicpd-torpedo-37xx-devkit-28: Reference new DRM panel Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 012/102] ARM: OMAP2+: Add missing put_device() call in omapdss_init_of() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 013/102] xfs: Sanity check flags of Q_XQUOTARM call Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 014/102] i2c: stm32f7: rework slave_id allocation Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 015/102] i2c: i2c-stm32f7: fix 10-bits check in slave free id search loop Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 016/102] mfd: intel-lpss: Add default I2C device properties for Gemini Lake Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 017/102] SUNRPC: Fix svcauth_gss_proxy_init() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 018/102] SUNRPC: Fix backchannel latency metrics Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 019/102] powerpc/security: Fix debugfs data leak on 32-bit Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 020/102] powerpc/pseries: Enable support for ibm,drc-info property Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 021/102] powerpc/kasan: Fix boot failure with RELOCATABLE && FSL_BOOKE Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 022/102] powerpc/archrandom: fix arch_get_random_seed_int() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 023/102] tipc: reduce sensitive to retransmit failures Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 024/102] tipc: update mons self addr when node addr generated Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 025/102] tipc: fix potential memory leak in __tipc_sendmsg() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 026/102] tipc: fix wrong socket reference counter after tipc_sk_timeout() returns Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 027/102] tipc: fix wrong timeout input for tipc_wait_for_cond() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 028/102] net/mlx5e: Fix free peer_flow when refcount is 0 Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 029/102] phy: lantiq: vrx200-pcie: fix error return code in ltq_vrx200_pcie_phy_power_on() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 030/102] net: phy: broadcom: Fix RGMII delays configuration for BCM54210E Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 031/102] phy: ti: gmii-sel: fix mac tx internal delay for rgmii-rxid Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 032/102] mt76: mt76u: fix endpoint definition order Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 033/102] mt7601u: fix bbp version check in mt7601u_wait_bbp_ready Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 034/102] ice: fix stack leakage Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 035/102] s390/pkey: fix memory leak within _copy_apqns_from_user() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 036/102] nfsd: depend on CRYPTO_MD5 for legacy client tracking Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 037/102] crypto: amcc - restore CRYPTO_AES dependency Greg Kroah-Hartman
2020-01-24  9:30 ` Greg Kroah-Hartman [this message]
2020-01-24  9:30 ` [PATCH 5.4 039/102] perf map: No need to adjust the long name of modules Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 040/102] leds: tlc591xx: update the maximum brightness Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 041/102] soc/tegra: pmc: Fix crashes for hierarchical interrupts Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 042/102] soc: qcom: llcc: Name regmaps to avoid collisions Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 043/102] soc: renesas: Add missing check for non-zero product register address Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 044/102] soc: aspeed: Fix snoop_file_poll()s return type Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 045/102] watchdog: sprd: Fix the incorrect pointer getting from driver data Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 046/102] ipmi: Fix memory leak in __ipmi_bmc_register Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 047/102] sched/core: Further clarify sched_class::set_next_task() Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 048/102] gpiolib: No need to call gpiochip_remove_pin_ranges() twice Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 049/102] rtw88: fix beaconing mode rsvd_page memory violation issue Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 050/102] rtw88: fix error handling when setup efuse info Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 051/102] drm/panfrost: Add missing check for pfdev->regulator Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 052/102] drm: panel-lvds: Potential Oops in probe error handling Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 053/102] drm/amdgpu: remove excess function parameter description Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 054/102] hwrng: omap3-rom - Fix missing clock by probing with device tree Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 055/102] dpaa2-eth: Fix minor bug in ethtool stats reporting Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 056/102] drm/rockchip: Round up _before_ giving to the clock framework Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 057/102] software node: Get reference to parent swnode in get_parent op Greg Kroah-Hartman
2020-01-24  9:30 ` [PATCH 5.4 058/102] PCI: mobiveil: Fix csr_read()/write() build issue Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 059/102] drm: rcar_lvds: Fix color mismatches on R-Car H2 ES2.0 and later Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 060/102] net: netsec: Correct dma sync for XDP_TX frames Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 061/102] ACPI: platform: Unregister stale platform devices Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 062/102] pwm: sun4i: Fix incorrect calculation of duty_cycle/period Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 063/102] regulator: bd70528: Add MODULE_ALIAS to allow module auto loading Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 064/102] drm/amdgpu/vi: silence an uninitialized variable warning Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 065/102] power: supply: bd70528: Add MODULE_ALIAS to allow module auto loading Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 066/102] firmware: imx: Remove call to devm_of_platform_populate Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 067/102] libbpf: Dont use kernel-side u32 type in xsk.c Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 068/102] rcu: Fix uninitialized variable in nocb_gp_wait() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 069/102] dpaa_eth: perform DMA unmapping before read Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 070/102] dpaa_eth: avoid timestamp read on error paths Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 071/102] scsi: ufs: delete redundant function ufshcd_def_desc_sizes() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 072/102] net: openvswitch: dont unlock mutex when changing the user_features fails Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 073/102] hv_netvsc: flag software created hash value Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 074/102] rt2800: remove errornous duplicate condition Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 075/102] net: neigh: use long type to store jiffies delta Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 076/102] net: axienet: Fix error return code in axienet_probe() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 077/102] selftests: gen_kselftest_tar.sh: Do not clobber kselftest/ Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 078/102] rtc: bd70528: fix module alias to autoload module Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 079/102] packet: fix data-race in fanout_flow_is_huge() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 080/102] i2c: stm32f7: report dma error during probe Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 081/102] kselftests: cgroup: Avoid the reuse of fd after it is deallocated Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 082/102] firmware: arm_scmi: Fix doorbell ring logic for !CONFIG_64BIT Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 083/102] mmc: sdio: fix wl1251 vendor id Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 084/102] mmc: core: fix wl1251 sdio quirks Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 085/102] tee: optee: Fix dynamic shm pool allocations Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 086/102] tee: optee: fix device enumeration error handling Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 087/102] workqueue: Add RCU annotation for pwq list walk Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 088/102] SUNRPC: Fix another issue with MIC buffer space Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 089/102] sched/cpufreq: Move the cfs_rq_util_change() call to cpufreq_update_util() Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 090/102] mt76: mt76u: rely on usb_interface instead of usb_dev Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 091/102] dma-direct: dont check swiotlb=force in dma_direct_map_resource Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 092/102] afs: Remove set but not used variables before, after Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 093/102] dmaengine: ti: edma: fix missed failure handling Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 094/102] drm/radeon: fix bad DMA from INTERRUPT_CNTL2 Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 095/102] xdp: Fix cleanup on map free for devmap_hash map type Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 096/102] platform/chrome: wilco_ec: fix use after free issue Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 097/102] block: fix memleak of bio integrity data Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 098/102] s390/qeth: fix dangling IO buffers after halt/clear Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 099/102] net-sysfs: Call dev_hold always in netdev_queue_add_kobject Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 100/102] gpio: aspeed: avoid return type warning Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 101/102] phy/rockchip: inno-hdmi: round clock rate down to closest 1000 Hz Greg Kroah-Hartman
2020-01-24  9:31 ` [PATCH 5.4 102/102] optee: Fix multi page dynamic shm pool alloc Greg Kroah-Hartman
2020-01-24 13:47 ` [PATCH 5.4 000/102] 5.4.15-stable review Naresh Kamboju
2020-01-24 14:52 ` Jon Hunter
2020-01-24 21:46 ` shuah
2020-01-25 13:51   ` Greg Kroah-Hartman
2020-01-24 23:56 ` Guenter Roeck
2020-01-25 13:52   ` Greg Kroah-Hartman
2020-01-25 10:22 ` Naresh Kamboju
2020-01-25 13:52   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200124092812.022914114@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=clabbe.montjoie@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).