From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Harald Freudenberger <freude@linux.vnet.ibm.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.5 03/60] crypto: s390 - fix des and des3_ede cbc concurrency issue
Date: Fri, 21 Feb 2014 13:00:30 +0000 [thread overview]
Message-ID: <1392987687-15367-4-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1392987687-15367-1-git-send-email-luis.henriques@canonical.com>
3.5.7.31 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <freude@linux.vnet.ibm.com>
commit adc3fcf1552b6e406d172fd9690bbd1395053d13 upstream.
In s390 des and des3_ede cbc mode the iv value is not protected
against concurrency access and modifications from another running
en/decrypt operation which is using the very same tfm struct
instance. This fix copies the iv to the local stack before
the crypto operation and stores the value back when done.
Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
arch/s390/crypto/des_s390.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index 00d649c..5fe77d5 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -106,29 +106,35 @@ static int ecb_desall_crypt(struct blkcipher_desc *desc, long func,
}
static int cbc_desall_crypt(struct blkcipher_desc *desc, long func,
- u8 *iv, struct blkcipher_walk *walk)
+ struct blkcipher_walk *walk)
{
+ struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
int ret = blkcipher_walk_virt(desc, walk);
unsigned int nbytes = walk->nbytes;
+ struct {
+ u8 iv[DES_BLOCK_SIZE];
+ u8 key[DES3_KEY_SIZE];
+ } param;
if (!nbytes)
goto out;
- memcpy(iv, walk->iv, DES_BLOCK_SIZE);
+ memcpy(param.iv, walk->iv, DES_BLOCK_SIZE);
+ memcpy(param.key, ctx->key, DES3_KEY_SIZE);
do {
/* only use complete blocks */
unsigned int n = nbytes & ~(DES_BLOCK_SIZE - 1);
u8 *out = walk->dst.virt.addr;
u8 *in = walk->src.virt.addr;
- ret = crypt_s390_kmc(func, iv, out, in, n);
+ ret = crypt_s390_kmc(func, ¶m, out, in, n);
if (ret < 0 || ret != n)
return -EIO;
nbytes &= DES_BLOCK_SIZE - 1;
ret = blkcipher_walk_done(desc, walk, nbytes);
} while ((nbytes = walk->nbytes));
- memcpy(walk->iv, iv, DES_BLOCK_SIZE);
+ memcpy(walk->iv, param.iv, DES_BLOCK_SIZE);
out:
return ret;
@@ -181,22 +187,20 @@ static int cbc_des_encrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
- struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
blkcipher_walk_init(&walk, dst, src, nbytes);
- return cbc_desall_crypt(desc, KMC_DEA_ENCRYPT, ctx->iv, &walk);
+ return cbc_desall_crypt(desc, KMC_DEA_ENCRYPT, &walk);
}
static int cbc_des_decrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
- struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
blkcipher_walk_init(&walk, dst, src, nbytes);
- return cbc_desall_crypt(desc, KMC_DEA_DECRYPT, ctx->iv, &walk);
+ return cbc_desall_crypt(desc, KMC_DEA_DECRYPT, &walk);
}
static struct crypto_alg cbc_des_alg = {
@@ -333,22 +337,20 @@ static int cbc_des3_encrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
- struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
blkcipher_walk_init(&walk, dst, src, nbytes);
- return cbc_desall_crypt(desc, KMC_TDEA_192_ENCRYPT, ctx->iv, &walk);
+ return cbc_desall_crypt(desc, KMC_TDEA_192_ENCRYPT, &walk);
}
static int cbc_des3_decrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
- struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
blkcipher_walk_init(&walk, dst, src, nbytes);
- return cbc_desall_crypt(desc, KMC_TDEA_192_DECRYPT, ctx->iv, &walk);
+ return cbc_desall_crypt(desc, KMC_TDEA_192_DECRYPT, &walk);
}
static struct crypto_alg cbc_des3_alg = {
--
1.9.0
next prev parent reply other threads:[~2014-02-21 13:27 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 13:00 [3.5.y.z extended stable] Linux 3.5.7.31 stable review Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 01/60] PCI: Enable ARI if dev and upstream bridge support it; disable otherwise Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 02/60] crypto: s390 - fix concurrency issue in aes-ctr mode Luis Henriques
2014-02-21 13:00 ` Luis Henriques [this message]
2014-02-21 13:00 ` [PATCH 3.5 04/60] crypto: s390 - fix des and des3_ede ctr concurrency issue Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 05/60] ALSA: usb-audio: Add missing kconfig dependecy Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 06/60] [media] mxl111sf: Fix unintentional garbage stack read Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 07/60] [media] mxl111sf: Fix compile when CONFIG_DVB_USB_MXL111SF is unset Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 08/60] drm/mgag200: fix typo causing bw limits to be ignored on some chips Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 09/60] ALSA: hda - Improve loopback path lookups for AD1983 Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 10/60] SELinux: Fix kernel BUG on empty security contexts Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 11/60] pinctrl: do not init debugfs entries for unimplemented functionalities Luis Henriques
2014-02-25 9:24 ` Linus Walleij
2014-02-25 9:38 ` Luís Henriques
2014-02-21 13:00 ` [PATCH 3.5 12/60] x86, hweight: Fix BUG when booting with CONFIG_GCOV_PROFILE_ALL=y Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 13/60] mm/swap: fix race on swap_info reuse between swapoff and swapon Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 14/60] mm: __set_page_dirty_nobuffers() uses spin_lock_irqsave() instead of spin_lock_irq() Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 15/60] mm: __set_page_dirty uses spin_lock_irqsave instead of spin_lock_irq Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 16/60] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 17/60] sched: Unthrottle rt runqueues in __disable_runtime() Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 18/60] sched/rt: Avoid updating RT entry timeout twice within one tick period Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 19/60] rtc-cmos: Add an alarm disable quirk Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 20/60] timekeeping: Avoid possible deadlock from clock_was_set_delayed Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 21/60] timekeeping: fix 32-bit overflow in get_monotonic_boottime Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 22/60] ahci: Use PCI_VENDOR_ID_MARVELL_EXT for 0x1b4b Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 23/60] ahci: add an observed PCI ID for Marvell 88se9172 SATA controller Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 24/60] ftrace: Synchronize setting function_trace_op with ftrace_trace_function Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 25/60] ftrace: Fix synchronization location disabling and freeing ftrace_ops Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 26/60] ftrace: Have function graph only trace based on global_ops filters Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 27/60] printk: Fix scheduling-while-atomic problem in console_cpu_notify() Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 28/60] staging:iio:ad799x fix error_free_irq which was freeing an irq that may not have been requested Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 29/60] xhci: Fix resume issues on Renesas chips in Samsung laptops Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 30/60] KVM: return an error code in kvm_vm_ioctl_register_coalesced_mmio() Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 31/60] power: max17040: Fix NULL pointer dereference when there is no platform_data Luis Henriques
2014-02-21 13:00 ` [PATCH 3.5 32/60] s390/dump: Fix dump memory detection Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 33/60] ath9k_htc: Do not support PowerSave by default Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 34/60] ath9k: " Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 35/60] spi: nuc900: Set SPI_LSB_FIRST for master->mode_bits if hw->pdata->lsb is true Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 36/60] usb: ftdi_sio: add Mindstorms EV3 console adapter Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 37/60] usb-storage: restrict bcdDevice range for Super Top in Cypress ATACB Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 38/60] usb-storage: add unusual-devs entry for BlackBerry 9000 Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 39/60] usb-storage: enable multi-LUN scanning when needed Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 40/60] USB: ftdi_sio: add Tagsys RFID Reader IDs Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 41/60] mac80211: fix fragmentation code, particularly for encryption Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 42/60] time: Fix overflow when HZ is smaller than 60 Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 43/60] VME: Correct read/write alignment algorithm Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 44/60] raw: test against runtime value of max_raw_minors Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 45/60] tty: n_gsm: Fix for modems with brk in modem status control Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 46/60] staging: comedi: adv_pci1710: fix analog output readback value Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 47/60] xen-blkfront: handle backend CLOSED without CLOSING Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 48/60] Modpost: fixed USB alias generation for ranges including 0x9 and 0xA Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 49/60] iio: ak8975: Fix calculation formula for convert micro tesla to gauss unit Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 50/60] fs/file.c:fdtable: avoid triggering OOMs from alloc_fdmem Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 51/60] genirq: Add missing irq_to_desc export for CONFIG_SPARSE_IRQ=n Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 52/60] ring-buffer: Fix first commit on sub-buffer having non-zero delta Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 53/60] usb: option: blacklist ZTE MF667 net interface Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 54/60] md/raid5: Fix CPU hotplug callback registration Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 55/60] lockd: send correct lock when granting a delayed lock Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 56/60] IB/qib: Add missing serdes init sequence Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 57/60] EDAC: Correct workqueue setup path Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 58/60] dm sysfs: fix a module unload race Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 59/60] s390: fix kernel crash due to linkage stack instructions Luis Henriques
2014-02-21 13:01 ` [PATCH 3.5 60/60] block: add cond_resched() to potentially long running ioctl discard loop Luis Henriques
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=1392987687-15367-4-git-send-email-luis.henriques@canonical.com \
--to=luis.henriques@canonical.com \
--cc=freude@linux.vnet.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=kernel-team@lists.ubuntu.com \
--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
all inboxes | Powered by JetHome®