Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3931730imm; Mon, 8 Oct 2018 11:54:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV60xDXdyFbrfzxV81qFpY/m3v/imQGUQwvMf7sz97SEocnl+QQdh0Le/zzVXFAreXOKezdFs X-Received: by 2002:a63:e141:: with SMTP id h1-v6mr22264332pgk.47.1539024845462; Mon, 08 Oct 2018 11:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024845; cv=none; d=google.com; s=arc-20160816; b=d0FmzadQVWnqdCG6gGdEvMJ66tUvWAtOB/e2TtbMrRekD7i3z6e9go2E8D1CNBATGj m7fgUL18Ga47zOx1UX3OR0N1wy3D4rNXnc36oy5vFQvNJdMsdSvMr/PioOP5HtKa1Zro AMk25tJqNAI3ZDMBFWsCnMnj7SPWmu0pWSTHAsWmt0QhKvtlZciiRvsGmG0hO3ADPKUP J0CyCNm4wGISYTJxjB9SY0gvJbjGUEePmCa5kwwoOBr1EmIqLBcRrcyne2A1DtvRAhdV HpHioSYEG4oYeVT6Z4ut+BG3S+sAzUE8/Tocqlkn3LoUUyzWMmTnXK2hH4oMMuSuuOAs DgkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fe2AkLM+dpuV/LuuhAuhyTw2tVDbDAc+j8HfZ5ZQckM=; b=vNj2SIOox4CRkSnefe0KpqRUmIIO/zKpznU46gpygPG73RrKZCNEMFsyFPVE0XpdD0 hmrB8y2B24zklhISvfZapPxySeNjh+xf5TvtzVd/CHdIkag8rXjGMppnO6evHzn8wEcV LDFqLejkrr3R5n6X5k8uedohNnE8CrEHpo/tgGMFs6B3Oq1dZXpoIIFaLzPCTwHtMjDj ULxRqhGiDLQGGXMu+Y1Rl3YNtaZ8UeI5gpt8gkv8s7FiHVKScfFD/zIBoFQBcrwXwMIJ OYmX6Y1Hit+WZ6OgKMEkC1pF29V/+RboArt8pZAsLZojLNrsEmmBODNlrfH4S4kQ7Ser woCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OoU+Sqn+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14-v6si17942622pgi.34.2018.10.08.11.53.50; Mon, 08 Oct 2018 11:54:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OoU+Sqn+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732774AbeJICGl (ORCPT + 99 others); Mon, 8 Oct 2018 22:06:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:57048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732766AbeJICGj (ORCPT ); Mon, 8 Oct 2018 22:06:39 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF2AB204FD; Mon, 8 Oct 2018 18:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024811; bh=izqbiM9eBhziAm0ScT1pajbUganM5hk6Zphmos+/0eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoU+Sqn+bGIvmdbJj86SOirHzn8ReaWEUrkkISSpSm7VpxxvoV356c15hOQIPbw8w FH6brNBIBU65sewL0WyUwVVf7/N2PLvhi9QlR8e9YzL5ro7jCLkPWs5iscIRQON1iR Tx3Hl894UeVdfKdKe3cRpdU4cmKdjStzKahYXXlk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Horia=20Geant=C4=83?= , Herbert Xu Subject: [PATCH 4.18 161/168] crypto: caam/jr - fix ablkcipher_edesc pointer arithmetic Date: Mon, 8 Oct 2018 20:32:21 +0200 Message-Id: <20181008175626.173258169@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Horia Geantă commit 13cc6f48c7434ce46ba6dbc90003a136a263d75a upstream. In some cases the zero-length hw_desc array at the end of ablkcipher_edesc struct requires for 4B of tail padding. Due to tail padding and the way pointers to S/G table and IV are computed: edesc->sec4_sg = (void *)edesc + sizeof(struct ablkcipher_edesc) + desc_bytes; iv = (u8 *)edesc->hw_desc + desc_bytes + sec4_sg_bytes; first 4 bytes of IV are overwritten by S/G table. Update computation of pointer to S/G table to rely on offset of hw_desc member and not on sizeof() operator. Cc: # 4.13+ Fixes: 115957bb3e59 ("crypto: caam - fix IV DMA mapping and updating") Signed-off-by: Horia Geantă Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/caam/caamalg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -1553,8 +1553,8 @@ static struct ablkcipher_edesc *ablkciph edesc->src_nents = src_nents; edesc->dst_nents = dst_nents; edesc->sec4_sg_bytes = sec4_sg_bytes; - edesc->sec4_sg = (void *)edesc + sizeof(struct ablkcipher_edesc) + - desc_bytes; + edesc->sec4_sg = (struct sec4_sg_entry *)((u8 *)edesc->hw_desc + + desc_bytes); edesc->iv_dir = DMA_TO_DEVICE; /* Make sure IV is located in a DMAable area */ @@ -1757,8 +1757,8 @@ static struct ablkcipher_edesc *ablkciph edesc->src_nents = src_nents; edesc->dst_nents = dst_nents; edesc->sec4_sg_bytes = sec4_sg_bytes; - edesc->sec4_sg = (void *)edesc + sizeof(struct ablkcipher_edesc) + - desc_bytes; + edesc->sec4_sg = (struct sec4_sg_entry *)((u8 *)edesc->hw_desc + + desc_bytes); edesc->iv_dir = DMA_FROM_DEVICE; /* Make sure IV is located in a DMAable area */