Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3944445imm; Mon, 8 Oct 2018 12:05:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aiZm1Ly/JlpLN056oqzl8dUGTj1qWDAwB7n1OZmGbSbErYqDFUhnQ/ux9vnNC6tLIkR5b X-Received: by 2002:a17:902:28a8:: with SMTP id f37-v6mr25575848plb.264.1539025534649; Mon, 08 Oct 2018 12:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539025534; cv=none; d=google.com; s=arc-20160816; b=gksjx5yglrV4hElXgVZiSs2iDlmEHAxo+Xnhu0WoKRgd8cwInYDyTNe1nzQkU78dq6 UKUV3+V69i1/E8sY4XCZD5SoV2lqHsqeM2jYakl/LY4/crJU0MQK6oN729+1et/bbmg+ 2eiMDpLIBzzd1NzzI0CRqIBj6frEta48LbfxA14EXReYjqXRnrn3AZGlOlfXc4cZVrik 4ReZ7gICELDy3xAiMVKtpVxbulnWEMq2IRFupGvVhwkk94y+1hbcgGSffTw1sXTI/yr9 i7X2tySu0AS45bm/ExJsGBDvr+850MbCFOx1QwUAqG99+MPKUyH1palXtCqCCFQyUMeq cBAw== 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=qBBdakC0TtI+sMi+bBz9ZI//ImOcstkp/ohMgRv4mzI=; b=EnF3p4s0Ixfm7Ehr5K29RYnHg0tn4lbTn8eySITFLifsr3L8JidzhNv/bb4mvCXmZ6 NQkOU8UHtx16WVQI2v5Lzm0fwx2nh5lts2/G5Rxq+o8hai+Nz2fixfPgKh0tglqidSHv RCi2YPNnZ6GCCk+4rr4zHWtgY7gZcb/2H4ikaeMxZNlHeZml9fWM0NLLWgyWzfIJ8n/E BSnFu1b1LqheD7/kk4OdRC1yKIdQCWqU0DmlSC5fJ/4zj5mAZQNVY5OEzFOhCO10oIJP QIbbb/8tH3KunoCfyfYJjT3PVtH93IHfI48+KiSMR3jXEaHSQIw9vM4Ye4dPycXUv5cp oWlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wOhfyUdA; 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 l1-v6si16853331pld.375.2018.10.08.12.05.18; Mon, 08 Oct 2018 12:05:34 -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=wOhfyUdA; 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 S1730868AbeJIB6B (ORCPT + 99 others); Mon, 8 Oct 2018 21:58:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730200AbeJIB6A (ORCPT ); Mon, 8 Oct 2018 21:58:00 -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 8C3122064A; Mon, 8 Oct 2018 18:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024295; bh=2ElbHuYDfDjmNFa8FJtDGJTxuc2bJdJx0pe9UKa11sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wOhfyUdAGP47ncgs8nCg34sKLEEGiEmSqC0VUW94wykPpBvQPiYrwHsGUMwCuMRpP hEdYiXjkAu7mG9P5uwQgqHlWe7qXi8drDvZJ657cv1GT1sPq4mhf1eALwbSGcc5kQY KlWJ/xsrmUKum1zSJlBvaRFq5n/UYSyeIlopMknU= 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.14 88/94] crypto: caam/jr - fix ablkcipher_edesc pointer arithmetic Date: Mon, 8 Oct 2018 20:32:09 +0200 Message-Id: <20181008175610.746392786@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175605.067676667@linuxfoundation.org> References: <20181008175605.067676667@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.14-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 @@ -1511,8 +1511,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 */ @@ -1715,8 +1715,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 */