From patchwork Mon May 20 12:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164634 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp246435ili; Mon, 20 May 2019 05:49:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwehaGJI8SRLFU1ZnwQ0vpoe3UH3MOdELmb4rD2BZrXe6ubkm8TfzzuzqQ9xQg2DH4zD9Jf X-Received: by 2002:a17:902:42a5:: with SMTP id h34mr53380311pld.178.1558356584914; Mon, 20 May 2019 05:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356584; cv=none; d=google.com; s=arc-20160816; b=X40KpJNhrfkohZz0xp5TNyDX7eAIvRrYrVXxFO3O2jwd4tBz+fXVsiQ6vTpfAfMGOv 6KQ4vv508BnhT8t3o/QParVX7D84pXIhe/JO0sqqFnhrGMRPPPjUeCD/WfdsCw+JSz8+ 4/sBshdC8oh7AOEYmx9ZHH3zoraAM0B1bFf7p3ptGMDPnJSP7kYCMEm8kDufmhtBH9k0 kPQTmKVCuer7iZ6f0q/gU9BvaUAWIJpxmA0G6byerk0BEl9SosTTeeRqekdD+1HtS55Y LzXgg7vi08DUGqW+4YNrClYN+1oaL/taUUoGIGBuwj0HIIb50lUrN8+a2MzgZyxAxkFp E/fQ== 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=t1igxxTsgiZBpZjq5+NokYAP6oSP0XgBIciliWpoY34=; b=N4swxPwkskobyNfBpfOPMqL2C4O9AR8eWW0K8gofvUaKKJR5UCo+IfVk0EPoQIeIYF 2MA/fcE98SMuKMWfr4fNw7ai8rUuK2gwsHFYWyqq97PIKKDA4fJ/1tsFUfc74UnjW6Rf RSJK/BpWnmULC+YpLKdm3t+wITOLGGLn3gboDWLY8ZKKNPjgXD5fPgcl031WQp8oqgM7 5TXZA2aDd7VKsDdKjXqlmvwgzY0WS4DWr+kujW2PU1zgUSe5mwqk2lgXo5ROqz5Fu0yv jW88G2YL3Ln5w9wMvzPZwiWidAznUn9vKdFO+32wsGBexhfUYI7nrVB0a3CP4p0i0SIX fthg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UOZkPQFU; 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 e11si12396932pgv.569.2019.05.20.05.49.41; Mon, 20 May 2019 05:49:44 -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=UOZkPQFU; 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 S2391514AbfETMqC (ORCPT + 30 others); Mon, 20 May 2019 08:46:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389306AbfETM0Y (ORCPT ); Mon, 20 May 2019 08:26:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 D20F320645; Mon, 20 May 2019 12:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355183; bh=jHnr8GD1aKn2Y3iOscmw3lW7VcwC0q2BQGI0AZcz3N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UOZkPQFU0SPLoEM707oyJweI5RwT5u51lwCfECV7GNFb3+zI7iXxvttGfXkfMLunS Cj2DG27PA6uGCjlrvVNjsYQr+fe7UXoXbjDU0vsXz+NYBz0Jzhb9WJBAUJSp2acVhU 2OqdInrZEbwS0HhJnhTKU+C15JLq1cBcB8gcpg4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Vincenzo Frascino , Thomas Gleixner , Will Deacon Subject: [PATCH 5.0 015/123] arm64: arch_timer: Ensure counter register reads occur with seqlock held Date: Mon, 20 May 2019 14:13:15 +0200 Message-Id: <20190520115246.047284657@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit 75a19a0202db21638a1c2b424afb867e1f9a2376 upstream. When executing clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads. Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths. Cc: Cc: Marc Zyngier Tested-by: Vincenzo Frascino Link: https://lore.kernel.org/linux-arm-kernel/alpine.DEB.2.21.1902081950260.1662@nanos.tec.linutronix.de/ Reported-by: Thomas Gleixner Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/arch_timer.h | 33 +++++++++++++++++++++++++++++++-- arch/arm64/kernel/vdso/gettimeofday.S | 15 +++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -148,18 +148,47 @@ static inline void arch_timer_set_cntkct isb(); } +/* + * Ensure that reads of the counter are treated the same as memory reads + * for the purposes of ordering by subsequent memory barriers. + * + * This insanity brought to you by speculative system register reads, + * out-of-order memory accesses, sequence locks and Thomas Gleixner. + * + * http://lists.infradead.org/pipermail/linux-arm-kernel/2019-February/631195.html + */ +#define arch_counter_enforce_ordering(val) do { \ + u64 tmp, _val = (val); \ + \ + asm volatile( \ + " eor %0, %1, %1\n" \ + " add %0, sp, %0\n" \ + " ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \ +} while (0) + static inline u64 arch_counter_get_cntpct(void) { + u64 cnt; + isb(); - return arch_timer_reg_read_stable(cntpct_el0); + cnt = arch_timer_reg_read_stable(cntpct_el0); + arch_counter_enforce_ordering(cnt); + return cnt; } static inline u64 arch_counter_get_cntvct(void) { + u64 cnt; + isb(); - return arch_timer_reg_read_stable(cntvct_el0); + cnt = arch_timer_reg_read_stable(cntvct_el0); + arch_counter_enforce_ordering(cnt); + return cnt; } +#undef arch_counter_enforce_ordering + static inline int arch_timer_arch_init(void) { return 0; --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S @@ -73,6 +73,13 @@ x_tmp .req x8 movn x_tmp, #0xff00, lsl #48 and \res, x_tmp, \res mul \res, \res, \mult + /* + * Fake address dependency from the value computed from the counter + * register to subsequent data page accesses so that the sequence + * locking also orders the read of the counter. + */ + and x_tmp, \res, xzr + add vdso_data, vdso_data, x_tmp .endm /* @@ -147,12 +154,12 @@ ENTRY(__kernel_gettimeofday) /* w11 = cs_mono_mult, w12 = cs_shift */ ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] - seqcnt_check fail=1b get_nsec_per_sec res=x9 lsl x9, x9, x12 get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 + seqcnt_check fail=1b get_ts_realtime res_sec=x10, res_nsec=x11, \ clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 @@ -211,13 +218,13 @@ realtime: /* w11 = cs_mono_mult, w12 = cs_shift */ ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] - seqcnt_check fail=realtime /* All computations are done with left-shifted nsecs. */ get_nsec_per_sec res=x9 lsl x9, x9, x12 get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 + seqcnt_check fail=realtime get_ts_realtime res_sec=x10, res_nsec=x11, \ clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 clock_gettime_return, shift=1 @@ -231,7 +238,6 @@ monotonic: ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] ldp x3, x4, [vdso_data, #VDSO_WTM_CLK_SEC] - seqcnt_check fail=monotonic /* All computations are done with left-shifted nsecs. */ lsl x4, x4, x12 @@ -239,6 +245,7 @@ monotonic: lsl x9, x9, x12 get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 + seqcnt_check fail=monotonic get_ts_realtime res_sec=x10, res_nsec=x11, \ clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 @@ -253,13 +260,13 @@ monotonic_raw: /* w11 = cs_raw_mult, w12 = cs_shift */ ldp w12, w11, [vdso_data, #VDSO_CS_SHIFT] ldp x13, x14, [vdso_data, #VDSO_RAW_TIME_SEC] - seqcnt_check fail=monotonic_raw /* All computations are done with left-shifted nsecs. */ get_nsec_per_sec res=x9 lsl x9, x9, x12 get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 + seqcnt_check fail=monotonic_raw get_ts_clock_raw res_sec=x10, res_nsec=x11, \ clock_nsec=x15, nsec_to_sec=x9 From patchwork Mon May 20 12:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164633 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp244447ili; Mon, 20 May 2019 05:47:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4/NIgwIlB94zciO7GxFc+Tkr7XxnnEJRyCqj0TpYGfy9gru7wY8JxVf14c82+aa4C8JqG X-Received: by 2002:a17:902:8d94:: with SMTP id v20mr6125405plo.99.1558356461831; Mon, 20 May 2019 05:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356461; cv=none; d=google.com; s=arc-20160816; b=fnCGiuF+8LkwAwXgD8nu9Grxq0ZOjuWUfnIdcCT6nTnR9BzU1HhTtNeyI3cLREd9Uk pvXS9p0oI0SC8bFLc8exgrSVCqaAliMS8YJnt2n93Cy3OzYH90FpkbVWhQ2Md9jIhe61 OWMlmGV0CtOpuzCz1+7gdihnKtf8mXXB54e7g9pqiUs8Ejr8mEesN57Y/TrjY7/zFojY j4pka8c8+LaXuKH+cdRNnemPmmWVfHLrioiQol+YD9/veweQYuTcXQ8VVRXSt3ZMeKrH E9w+ruv3DXJGrEJtvVKps7C7uYskxNKdLnCmu+RVJPggsL7on0FfwAerfezNw7gnrcRM dYmA== 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=r8uPgyUeCKZj+u1oFM/J+1e3esHunGPP7dCdNrZZqNQ=; b=NBxSEJaFRBTqf+g4EVlFfBCgC54kY1zKVbUNSpWg6LfaV/o5ihudhI0zcCHtU6de+O 5kAzEQnHjITPgq/fKpi9PAMtxxJW1SGiqECj0r+UzwxbPxji9iapFaMGlaYsuEnJnd1b u7/Z59O7Mx4z1GKFYt41TXlC76Rur/ekz/rD2D2+1qE4u4NjZtJIissunwt4vDGr/Inu c0Iszldx7P5tiuXqCb5UyA4SmuW6UPhsxzDvdna6YDsdJaJvWbrAN7uxY13/0rhqz2ru x4xIAXMpRsaOpwbfe+SkzLNin0UOwJn2rvv6InMHhqEJ1bGk+MOR2IkToAsMneaX2Wv4 nQcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pwG1MdEX; 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 e11si12396932pgv.569.2019.05.20.05.47.37; Mon, 20 May 2019 05:47:41 -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=pwG1MdEX; 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 S2390082AbfETMoM (ORCPT + 30 others); Mon, 20 May 2019 08:44:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:44042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388531AbfETM2S (ORCPT ); Mon, 20 May 2019 08:28:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E8A7020675; Mon, 20 May 2019 12:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355297; bh=t4YPewq3D+jh2vmXPVGr1+GWoDZMuOUNpivSsGEzJiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pwG1MdEX2FpkH4bLzpVLOsR24Rrn4kP8FCOxy5ARu/scApGK7oaW9gGsEcsbXzb30 0qTVmykWC0xHK3YQsvZjI5UOkznp5SYO87/4ovNW4uAyNMn5xzCUpmROAVbBkx6mw/ G9KnXv/lTJw1KM9xlK/KhMfYuSAZpQQN9uxFtAsg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 058/123] crypto: ccree - remove special handling of chained sg Date: Mon, 20 May 2019 14:13:58 +0200 Message-Id: <20190520115248.625474677@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gilad Ben-Yossef commit c4b22bf51b815fb61a35a27fc847a88bc28ebb63 upstream. We were handling chained scattergather lists with specialized code needlessly as the regular sg APIs handle them just fine. The code handling this also had an (unused) code path with a use-before-init error, flagged by Coverity. Remove all special handling of chained sg and leave their handling to the regular sg APIs. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_buffer_mgr.c | 98 +++++++---------------------------- 1 file changed, 22 insertions(+), 76 deletions(-) --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -83,24 +83,17 @@ static void cc_copy_mac(struct device *d */ static unsigned int cc_get_sgl_nents(struct device *dev, struct scatterlist *sg_list, - unsigned int nbytes, u32 *lbytes, - bool *is_chained) + unsigned int nbytes, u32 *lbytes) { unsigned int nents = 0; while (nbytes && sg_list) { - if (sg_list->length) { - nents++; - /* get the number of bytes in the last entry */ - *lbytes = nbytes; - nbytes -= (sg_list->length > nbytes) ? - nbytes : sg_list->length; - sg_list = sg_next(sg_list); - } else { - sg_list = (struct scatterlist *)sg_page(sg_list); - if (is_chained) - *is_chained = true; - } + nents++; + /* get the number of bytes in the last entry */ + *lbytes = nbytes; + nbytes -= (sg_list->length > nbytes) ? + nbytes : sg_list->length; + sg_list = sg_next(sg_list); } dev_dbg(dev, "nents %d last bytes %d\n", nents, *lbytes); return nents; @@ -142,7 +135,7 @@ void cc_copy_sg_portion(struct device *d { u32 nents, lbytes; - nents = cc_get_sgl_nents(dev, sg, end, &lbytes, NULL); + nents = cc_get_sgl_nents(dev, sg, end, &lbytes); sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, (direct == CC_SG_TO_BUF)); } @@ -311,40 +304,10 @@ static void cc_add_sg_entry(struct devic sgl_data->num_of_buffers++; } -static int cc_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents, - enum dma_data_direction direction) -{ - u32 i, j; - struct scatterlist *l_sg = sg; - - for (i = 0; i < nents; i++) { - if (!l_sg) - break; - if (dma_map_sg(dev, l_sg, 1, direction) != 1) { - dev_err(dev, "dma_map_page() sg buffer failed\n"); - goto err; - } - l_sg = sg_next(l_sg); - } - return nents; - -err: - /* Restore mapped parts */ - for (j = 0; j < i; j++) { - if (!sg) - break; - dma_unmap_sg(dev, sg, 1, direction); - sg = sg_next(sg); - } - return 0; -} - static int cc_map_sg(struct device *dev, struct scatterlist *sg, unsigned int nbytes, int direction, u32 *nents, u32 max_sg_nents, u32 *lbytes, u32 *mapped_nents) { - bool is_chained = false; - if (sg_is_last(sg)) { /* One entry only case -set to DLLI */ if (dma_map_sg(dev, sg, 1, direction) != 1) { @@ -358,35 +321,21 @@ static int cc_map_sg(struct device *dev, *nents = 1; *mapped_nents = 1; } else { /*sg_is_last*/ - *nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes, - &is_chained); + *nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes); if (*nents > max_sg_nents) { *nents = 0; dev_err(dev, "Too many fragments. current %d max %d\n", *nents, max_sg_nents); return -ENOMEM; } - if (!is_chained) { - /* In case of mmu the number of mapped nents might - * be changed from the original sgl nents - */ - *mapped_nents = dma_map_sg(dev, sg, *nents, direction); - if (*mapped_nents == 0) { - *nents = 0; - dev_err(dev, "dma_map_sg() sg buffer failed\n"); - return -ENOMEM; - } - } else { - /*In this case the driver maps entry by entry so it - * must have the same nents before and after map - */ - *mapped_nents = cc_dma_map_sg(dev, sg, *nents, - direction); - if (*mapped_nents != *nents) { - *nents = *mapped_nents; - dev_err(dev, "dma_map_sg() sg buffer failed\n"); - return -ENOMEM; - } + /* In case of mmu the number of mapped nents might + * be changed from the original sgl nents + */ + *mapped_nents = dma_map_sg(dev, sg, *nents, direction); + if (*mapped_nents == 0) { + *nents = 0; + dev_err(dev, "dma_map_sg() sg buffer failed\n"); + return -ENOMEM; } } @@ -571,7 +520,6 @@ void cc_unmap_aead_request(struct device struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct cc_drvdata *drvdata = dev_get_drvdata(dev); u32 dummy; - bool chained; u32 size_to_unmap = 0; if (areq_ctx->mac_buf_dma_addr) { @@ -636,15 +584,14 @@ void cc_unmap_aead_request(struct device size_to_unmap += crypto_aead_ivsize(tfm); dma_unmap_sg(dev, req->src, - cc_get_sgl_nents(dev, req->src, size_to_unmap, - &dummy, &chained), + cc_get_sgl_nents(dev, req->src, size_to_unmap, &dummy), DMA_BIDIRECTIONAL); if (req->src != req->dst) { dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", sg_virt(req->dst)); dma_unmap_sg(dev, req->dst, cc_get_sgl_nents(dev, req->dst, size_to_unmap, - &dummy, &chained), + &dummy), DMA_BIDIRECTIONAL); } if (drvdata->coherent && @@ -1022,7 +969,6 @@ static int cc_aead_chain_data(struct cc_ unsigned int size_for_map = req->assoclen + req->cryptlen; struct crypto_aead *tfm = crypto_aead_reqtfm(req); u32 sg_index = 0; - bool chained = false; bool is_gcm4543 = areq_ctx->is_gcm4543; u32 size_to_skip = req->assoclen; @@ -1043,7 +989,7 @@ static int cc_aead_chain_data(struct cc_ size_for_map += (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? authsize : 0; src_mapped_nents = cc_get_sgl_nents(dev, req->src, size_for_map, - &src_last_bytes, &chained); + &src_last_bytes); sg_index = areq_ctx->src_sgl->length; //check where the data starts while (sg_index <= size_to_skip) { @@ -1085,7 +1031,7 @@ static int cc_aead_chain_data(struct cc_ } dst_mapped_nents = cc_get_sgl_nents(dev, req->dst, size_for_map, - &dst_last_bytes, &chained); + &dst_last_bytes); sg_index = areq_ctx->dst_sgl->length; offset = size_to_skip; @@ -1486,7 +1432,7 @@ int cc_map_hash_request_update(struct cc dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); areq_ctx->in_nents = - cc_get_sgl_nents(dev, src, nbytes, &dummy, NULL); + cc_get_sgl_nents(dev, src, nbytes, &dummy); sg_copy_to_buffer(src, areq_ctx->in_nents, &curr_buff[*curr_buff_cnt], nbytes); *curr_buff_cnt += nbytes; From patchwork Mon May 20 12:13:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164632 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp243841ili; Mon, 20 May 2019 05:47:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvI06G8j2EOFY0NNWpHB7hO5BAZW+hwvFEvBU2nnVp3XR+FBqCrX4hgpcNopwd5CqpytLb X-Received: by 2002:a17:902:6a83:: with SMTP id n3mr76271216plk.109.1558356424345; Mon, 20 May 2019 05:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356424; cv=none; d=google.com; s=arc-20160816; b=eitBcPm7t+y5IIZmjsKsu1MEpmp73W0U/AXtTWxDek1aXsp4U3DbBoa3HlkLkhB12C RPDP2tmYQgXx7aFwk9XbretIoPM5THCdiL6BW90EUQFbHhrgJXWrJFS4iyoHxObB4SUV gfsiyk4GI03NGFJKHLKxGaodgK3CNbsrFXHhKH6yeoB2G2vZhFfb3u5A0mOleUTui01H FwzOgf/mf46MoRxwe+xtx4glV9+uyUcju0onF8veI9lk/sxmGHl36O4yXrci1Y+Vg+Qn Ik+f5S3G9R1qtJGszE9e9eH13175qGH6r8+uKmQnhgoENWcmj6kdf4loYzhIj8b2U9My dwtA== 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=TEOjFFbIAKtWDVj7b5kOGp66OjQtTgLzbcPkVCXl414=; b=q2v8XFdecZVPKHQHC/wTk60OOWd/gtcUbu+9V6R6RF1kpNecqZUw+DK2oYh5YaMKuq bJE/sP0nIzbXriHX6ZdJKIIbnO+rh4hcrTIxko42xQc+4z2OnV1cO4KOtZ1AGzlKiKx5 oLxohvZ5m5jQctJhlbDcI+1xcgwkQdzUCgJ7b/zUGDh/0zPOAmppad2+M2yGu2cotWgD VXP3mW5RTUL4OhDAMo+lHA3+5rKeIJgxhBUi34gbBTaDgD/l5uUTC0CcHC/9C9DSm7EW DjM/iIYIDbC8UWCSPokZo/Yjm7pzzzMNSt1+Onr/Fy6T5lhPf7Hua2Rmu6/0ozbs7AEG pxhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u3fL8GWx; 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 e11si12396932pgv.569.2019.05.20.05.47.00; Mon, 20 May 2019 05:47:04 -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=u3fL8GWx; 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 S2390969AbfETMnp (ORCPT + 30 others); Mon, 20 May 2019 08:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389741AbfETM2q (ORCPT ); Mon, 20 May 2019 08:28:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 DB4BA20645; Mon, 20 May 2019 12:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355325; bh=Vc76SIEwx46ODrXQqltdqyN2/mHnKSGbQiibyzx/1hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3fL8GWx5H2E4fXJg3vZp359nb0eI5emHn+kqjplqzM/GTfYpaMckmXA6Pl+TPpx6 oBvKj/PkRcW4OkY+ZYpHidy4Nsmf99tghxty7lPg4VjJJuhIiNO6n2a9yLd+Edrm1r HhBsRxGBZDRHdEPFnrMaX3ptgIWKFiet+Q2YJlkM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 059/123] crypto: ccree - fix mem leak on error path Date: Mon, 20 May 2019 14:13:59 +0200 Message-Id: <20190520115248.697804651@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gilad Ben-Yossef commit d574b707c873d6ef1a2a155f8cfcfecd821e9a2e upstream. Fix a memory leak on the error path of IV generation code. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_ivgen.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/crypto/ccree/cc_ivgen.c +++ b/drivers/crypto/ccree/cc_ivgen.c @@ -154,9 +154,6 @@ void cc_ivgen_fini(struct cc_drvdata *dr } ivgen_ctx->pool = NULL_SRAM_ADDR; - - /* release "this" context */ - kfree(ivgen_ctx); } /*! @@ -174,10 +171,12 @@ int cc_ivgen_init(struct cc_drvdata *drv int rc; /* Allocate "this" context */ - ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL); + ivgen_ctx = devm_kzalloc(device, sizeof(*ivgen_ctx), GFP_KERNEL); if (!ivgen_ctx) return -ENOMEM; + drvdata->ivgen_handle = ivgen_ctx; + /* Allocate pool's header for initial enc. key/IV */ ivgen_ctx->pool_meta = dma_alloc_coherent(device, CC_IVPOOL_META_SIZE, &ivgen_ctx->pool_meta_dma, @@ -196,8 +195,6 @@ int cc_ivgen_init(struct cc_drvdata *drv goto out; } - drvdata->ivgen_handle = ivgen_ctx; - return cc_init_iv_sram(drvdata); out: From patchwork Mon May 20 12:14:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164631 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp242638ili; Mon, 20 May 2019 05:45:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8WY2IDQnvN+L3c9FyI4xfMFs+Q347g9PaJAWBs9fi7c+4ii60s1VTDlQyuLbOCBRL7cJL X-Received: by 2002:a65:4144:: with SMTP id x4mr16790078pgp.282.1558356355191; Mon, 20 May 2019 05:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356355; cv=none; d=google.com; s=arc-20160816; b=hejP7jx1AwOkI58xmkXjhDvRip2kEmGY2mPhcQYUMAGrMDMOTw23gwvAJ9oF9kIbWZ CgItO6+XzZY/XtTarTsKaTjZ88nWIp3+S2n2Nq9gR39KjLebFUYPyDYYUi1onPAeSjUd 18w/PyaSf0/v0ZjNLDE+cxkelHOT7rHJLul7okU2fP/LCRqUjAsRNq13ROq0FDswzSaR Vr43OKM/UGvMxB4VEUwrPRhIXFUO3rKwOT1XFpMQOxygo389wCQMOgxZD+B53gYFaFju cJrjJP8oo1/xg5SV4aleVkJjTKzQxbaggEDgYhoawvnK5PkbMlvPlVnHoMS+qUS+B9i5 dOTA== 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=LtroVFnyPKtphhy4gu8/w51VaQjDJn9KLsOjVGnTQlo=; b=joSj4vpztn+ZudemYPgD7cBaSS1PgWYfjckhvmJ42yLY1EPmg3c3pRU+4eyU7/olGv QM0NO4jBZCEeGCacKkmFOJnK8ml9SfuSxWaTeiPCIlzVURiFEZOi8bNxbqwaw005REs6 AkoYKCoODmEdCMG8evBAPSM1y3VZiYgwU9VFBczn3wuS1MrGc7mHFSieMluJyJ9Kwu6a r0MxD6ShH7lq2UZb38u83gssWO9/ReNjJTI0AGv04VBxIp75kJTcMq85P4S89MFYyrGv /nZD9kRsZayq/hOC5p556VF2x24nkOBj191wwE+hU3QZvTObS+Ubag6glzsdXB9Jmqvi XPCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yjPbh4PX; 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 e11si12396932pgv.569.2019.05.20.05.45.51; Mon, 20 May 2019 05:45:55 -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=yjPbh4PX; 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 S2389968AbfETM3s (ORCPT + 30 others); Mon, 20 May 2019 08:29:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:45880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388848AbfETM3o (ORCPT ); Mon, 20 May 2019 08:29:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 EC592216C4; Mon, 20 May 2019 12:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355383; bh=N8d2+4SnFNE53BBI5L7qN6qxAsHj6sYtOtlPLCR3Gi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yjPbh4PXCBEIQXIoosG3VbObPE+NbO10pniIilzhOtxiu2YXSDoCtoV8L6CIoLu5e OIQf8TBnWEg2cT4t1+NyfdCd0q1npjiSqqEihSKUJkW7d7PHp33FnMKt9AL3XJGuxH JosPy/8RNoidAQCcCHuojR2sy5/tywBaA7cFspeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 061/123] crypto: ccree - use correct internal state sizes for export Date: Mon, 20 May 2019 14:14:01 +0200 Message-Id: <20190520115248.849293422@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gilad Ben-Yossef commit f3df82b468f00cca241d96ee3697c9a5e7fb6bd0 upstream. We were computing the size of the import buffer based on the digest size but the 318 and 224 byte variants use 512 and 256 bytes internal state sizes respectfully, thus causing the import buffer to overrun. Fix it by using the right sizes. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/crypto/ccree/cc_hash.c +++ b/drivers/crypto/ccree/cc_hash.c @@ -1639,7 +1639,7 @@ static struct cc_hash_template driver_ha .setkey = cc_hash_setkey, .halg = { .digestsize = SHA224_DIGEST_SIZE, - .statesize = CC_STATE_SIZE(SHA224_DIGEST_SIZE), + .statesize = CC_STATE_SIZE(SHA256_DIGEST_SIZE), }, }, .hash_mode = DRV_HASH_SHA224, @@ -1666,7 +1666,7 @@ static struct cc_hash_template driver_ha .setkey = cc_hash_setkey, .halg = { .digestsize = SHA384_DIGEST_SIZE, - .statesize = CC_STATE_SIZE(SHA384_DIGEST_SIZE), + .statesize = CC_STATE_SIZE(SHA512_DIGEST_SIZE), }, }, .hash_mode = DRV_HASH_SHA384, From patchwork Mon May 20 12:14:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164617 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp225965ili; Mon, 20 May 2019 05:30:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkBqnUW16up7x8QfHEzZpb5svW60wRA3kugX6naLpXUvgwknGGf11/XCObjmA8KuKQmy1O X-Received: by 2002:aa7:9a99:: with SMTP id w25mr40632134pfi.249.1558355412390; Mon, 20 May 2019 05:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355412; cv=none; d=google.com; s=arc-20160816; b=aK4BvTbGOIVZPdFbHM7Nu8NcqUxu30pX69WxiwDQDBSGR2GykBcCzS9iQi1CK9V+B6 4q8vmDIbMpZL++lgbX3FMegHHWzo0lU4w+xgEKGwyB0bkaFPSgY8xNyUbbmS/0OqEWDW FroVZNlB3NKs55J2TNoAB88qlMfMydR1Bk+k+TXA9hkSo0jmLzZ+UqH4QzOsXCc288Ze vRkDLQhq2VeH+pe7mR1KBjN4TzrNc9W3l/49Q6935nYpD+m7/MVGJYks0xxHFTcvZ2Ex 8AI5bqZC4eqk3BL23vuuMKrwP1JEroL/LLbIkQJtnuJ3Bkkq/hznPtuyRHeui5jXTkNh yCEQ== 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=qqwj2dkUx+ur/a/tog/DfPiMH4JjlCcX+Gpm0wKqRvM=; b=jgaNctbK7Dt5CVopNU3UoXacBccKjIsvmUtMqBtQRg2pAA9QvHwTmXY2P2gzTU4AXq Ydv8DjhtGL4zAxFfjo/LzQ/Mze/sH5I9BUvETfRMKPnxR+TYJHSydxpMhFeSgtIhj+r8 yzA/DpAs2/dCOuWoyItWVf5YFOIUC0S2f07O/LZnJxpClzkifJT+LnuQZ67Qk9QPBnUE SDxP0rCSjxYXmwuWnXtsc+xIFLExZzNQv9bn/qvfprQb0EPaHhUtqkKBGwn1O5wBy/Og dicuY8Ave/XGeH+ccPX6MQ/leD8aof96I95SlLCDcQznGG0U8s17v/kwondp/EQRdq2e hOSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=crIPmrwA; 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 186si18145232pfc.247.2019.05.20.05.30.12; Mon, 20 May 2019 05:30:12 -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=crIPmrwA; 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 S2390043AbfETMaL (ORCPT + 30 others); Mon, 20 May 2019 08:30:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:46326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389584AbfETMaF (ORCPT ); Mon, 20 May 2019 08:30:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4881421479; Mon, 20 May 2019 12:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355404; bh=UH6JkK6X0kuRS9HGzftnJ0yrDm0rxbG8gjI3mS3bbjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crIPmrwABNaxYXhQ8xH0YxnN5a8BbKZYTJo0BzZTHxJ/00og/iX37pPaI8jpqg3Es oaV/wHKS9RDDtTlDWpJATA5Gf+qTexriIhX0qDl33ITKuapVLrz0BYlGmE0vyvnu+m XzeNkyRn5p5IecQj4B/lHmtFUpOemAi3NoE92Q44= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Drang , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 065/123] crypto: ccree - add function to handle cryptocell tee fips error Date: Mon, 20 May 2019 14:14:05 +0200 Message-Id: <20190520115249.137222777@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Drang commit 897ab2316910a66bb048f1c9cefa25e6a592dcd7 upstream. Adds function that checks if cryptocell tee fips error occurred and in such case triggers system error through kernel panic. Change fips function to use this new routine. Signed-off-by: Ofir Drang Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_fips.c | 23 +++++++++++++++-------- drivers/crypto/ccree/cc_fips.h | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) --- a/drivers/crypto/ccree/cc_fips.c +++ b/drivers/crypto/ccree/cc_fips.c @@ -72,20 +72,28 @@ static inline void tee_fips_error(struct dev_err(dev, "TEE reported error!\n"); } +/* + * This function check if cryptocell tee fips error occurred + * and in such case triggers system error + */ +void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata) +{ + struct device *dev = drvdata_to_dev(p_drvdata); + + if (!cc_get_tee_fips_status(p_drvdata)) + tee_fips_error(dev); +} + /* Deferred service handler, run as interrupt-fired tasklet */ static void fips_dsr(unsigned long devarg) { struct cc_drvdata *drvdata = (struct cc_drvdata *)devarg; - struct device *dev = drvdata_to_dev(drvdata); - u32 irq, state, val; + u32 irq, val; irq = (drvdata->irq & (CC_GPR0_IRQ_MASK)); if (irq) { - state = cc_ioread(drvdata, CC_REG(GPR_HOST)); - - if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK)) - tee_fips_error(dev); + cc_tee_handle_fips_error(drvdata); } /* after verifing that there is nothing to do, @@ -113,8 +121,7 @@ int cc_fips_init(struct cc_drvdata *p_dr dev_dbg(dev, "Initializing fips tasklet\n"); tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata); - if (!cc_get_tee_fips_status(p_drvdata)) - tee_fips_error(dev); + cc_tee_handle_fips_error(p_drvdata); return 0; } --- a/drivers/crypto/ccree/cc_fips.h +++ b/drivers/crypto/ccree/cc_fips.h @@ -18,6 +18,7 @@ int cc_fips_init(struct cc_drvdata *p_dr void cc_fips_fini(struct cc_drvdata *drvdata); void fips_handler(struct cc_drvdata *drvdata); void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok); +void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata); #else /* CONFIG_CRYPTO_FIPS */ @@ -30,6 +31,7 @@ static inline void cc_fips_fini(struct c static inline void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok) {} static inline void fips_handler(struct cc_drvdata *drvdata) {} +static inline void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata) {} #endif /* CONFIG_CRYPTO_FIPS */ From patchwork Mon May 20 12:14:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164618 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp226250ili; Mon, 20 May 2019 05:30:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSStonOGJQRx7WiJ4/zRXbDpbZO39PUE5owDTOPeCbgsWcaBxM69ZBWjYykbFWcS+9Ydio X-Received: by 2002:a17:902:5e1:: with SMTP id f88mr28261089plf.226.1558355426223; Mon, 20 May 2019 05:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355426; cv=none; d=google.com; s=arc-20160816; b=go46H/CJZNmjkEMirjE3+A0IqbgFRpQliKrBa8XS9kEJajCdTO8ZlrOSI9gOERneQl zLmwDLKNSwAYWKAZvB2ovO68apqVwfEVKyiruPl6S6Spna2tOwmz4USKvsm2a0YL0qwj ETgBEiIQ32TfKZgdQuLPxlovnKoXVaTpypFt7MS9d5TxguWQ9+jgpQogwm4rdc4Wmz2R 4HR00ghoFRM7YTTQ8W02nByO2oRIvuew1nF2Vj18OEKs9RgNcgdpurs0aipufNB2ftHL mivUfMw+Cc7mquXJuNO8vomhz+TVUFM2VXE9m1qCFCVfjCMlniptQEhFu6cdf4OBbWlK axIw== 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=0kDs8iyG6P/4vkUaF57U5KHE3mGwbNUL5gy/eSWV5/g=; b=ch41GcSk5KzVyhUFUQLh68HwjoJMs7stURcSFe1BE1jI6husH7qOOTGdiYiyy1T1OP ZTPaa00SYawZ1Ltya05GLa95zI7EOaeXXBOAFbc6FEdEHV8j+heHYat68bP+mgpaHPoF vrK4YwDU101f4IyzPfnaAZ6gG+8kr/HA1o+2KQyGKCem708Oc4e4QjcUSiAl83om46XJ Wc4E5VPUbl9RMg8ov9xtuy7JSzvpMl/2ejciORDRuz5SpXO76eytVY3k7t4mg964Yohl jafSq+RdzIEP7q7CRJ4YS7bXjaiITyk5P0vk2+//5mDiS500JQ+e3hzVm1towRMNHAoP vpNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eVZCEe5r; 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 h93si18783512plb.256.2019.05.20.05.30.25; Mon, 20 May 2019 05:30:26 -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=eVZCEe5r; 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 S2390096AbfETMaZ (ORCPT + 30 others); Mon, 20 May 2019 08:30:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:46624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390079AbfETMaV (ORCPT ); Mon, 20 May 2019 08:30:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 78A4120815; Mon, 20 May 2019 12:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355421; bh=0FbrDWa298P0Lw1YpNogfvug+ahYvm4drwjTmQXsT8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVZCEe5rA6irdMakEpLObOVFbmQAdf0h1myaKd5awtQ8m12ellGx5kkfhN7p2v49i ZC4Yq/h/qGAN2XYpPVCuRibnGxcCZioqH1FgirVpXgJ6H4O3x91eVBRkLxk/G7JGHo HBI33U1dA5vDlAt+ypRFK2tuOwIf3doP2U2OyAjM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada Subject: [PATCH 5.0 113/123] kbuild: turn auto.conf.cmd into a mandatory include file Date: Mon, 20 May 2019 14:14:53 +0200 Message-Id: <20190520115252.654159903@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada commit d2f8ae0e4c5c754f1b2a7b8388d19a1a977e698a upstream. syncconfig is responsible for keeping auto.conf up-to-date, so if it fails for any reason, the build must be terminated immediately. However, since commit 9390dff66a52 ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing"), Kbuild continues running even after syncconfig fails. You can confirm this by intentionally making syncconfig error out: # diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c # index 08ba146..307b9de 100644 # --- a/scripts/kconfig/confdata.c # +++ b/scripts/kconfig/confdata.c # @@ -1023,6 +1023,9 @@ int conf_write_autoconf(int overwrite) # FILE *out, *tristate, *out_h; # int i; # # + if (overwrite) # + return 1; # + # if (!overwrite && is_present(autoconf_name)) # return 0; Then, syncconfig fails, but Make would not stop: $ make -s mrproper allyesconfig defconfig $ make scripts/kconfig/conf --syncconfig Kconfig *** Error during sync of the configuration. make[2]: *** [scripts/kconfig/Makefile;69: syncconfig] Error 1 make[1]: *** [Makefile;557: syncconfig] Error 2 make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf' make: Failed to remake makefile 'include/config/auto.conf'. SYSTBL arch/x86/include/generated/asm/syscalls_32.h SYSHDR arch/x86/include/generated/asm/unistd_32_ia32.h SYSHDR arch/x86/include/generated/asm/unistd_64_x32.h SYSTBL arch/x86/include/generated/asm/syscalls_64.h [ continue running ... ] The reason is in the behavior of a pattern rule with multi-targets. %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig GNU Make knows this rule is responsible for making all the three files simultaneously. As far as examined, auto.conf.cmd is the target in question when this rule is invoked. It is probably because auto.conf.cmd is included below the inclusion of auto.conf. The inclusion of auto.conf is mandatory, while that of auto.conf.cmd is optional. GNU Make does not care about the failure in the process of updating optional include files. I filed this issue (https://savannah.gnu.org/bugs/?56301) in case this behavior could be improved somehow in future releases of GNU Make. Anyway, it is quite easy to fix our Makefile. Given that auto.conf is already a mandatory include file, there is no reason to stick auto.conf.cmd optional. Make it mandatory as well. Cc: linux-stable # 5.0+ Fixes: 9390dff66a52 ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing") Signed-off-by: Masahiro Yamada [commented out diff above to keep patch happy - gregkh] Signed-off-by: Greg Kroah-Hartman --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/Makefile +++ b/Makefile @@ -642,7 +642,7 @@ ifeq ($(may-sync-config),1) # Read in dependencies to all Kconfig* files, make sure to run syncconfig if # changes are detected. This should be included after arch/$(SRCARCH)/Makefile # because some architectures define CROSS_COMPILE there. --include include/config/auto.conf.cmd +include include/config/auto.conf.cmd # To avoid any implicit rule to kick in, define an empty command $(KCONFIG_CONFIG): ;