Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp688307yba; Thu, 16 May 2019 07:26:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHerIoHSDnI7BMQbBbWr5SU8kLjH7cMdwZwSXFqjGkQ6imd8mCxMMZX5oGrB+26IXcMpMo X-Received: by 2002:a63:5f42:: with SMTP id t63mr49941398pgb.275.1558016767234; Thu, 16 May 2019 07:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558016767; cv=none; d=google.com; s=arc-20160816; b=0N5tD92ywfmLBhSvDg3knJ0Qd80USHgHGMoZPy0Iu1WQy8IIEdiTdo3QBhlEL4LrJ4 5ut/25c6UsO+33DrSILtjSIhLfes1iXgNQfBwmx0qg2d6lsA3QegBrhOtw5/y3Gs54un VXouc2pr2l1Zac07C3sOwa5jtiuFis48vaCJbAHW3keTzkkFwxoYOcb6JUjnN9c9EEUp MXgbSQ+3yfczLD40K+ltUyaW6XNaBim98uz4wmqxlP3C10NtXp5e5Rr+OgqJVrgSX7CX cQl4J4ArF9zSWvmtol3udOnBVgIe/AqjTyA0E60Xj0GzeMUNS3TjCBCJzBQGhLnBCLrT M3yA== 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 :message-id:date:subject:cc:to:from; bh=3+EQhoQ2J8brkzPoBnoZimk4AIhSYmWXjP4Hqutq77E=; b=GaNWAQlFo7X4mgjEVgBdSByMxAgFoewYKxI8XITLnvVuZjlDci9d0pgf1JrzWsS6Nc +CsyBZGPGEmEhe5gtoABUmHuqplKpiy5EmWZnghbs6xPChG4mkyVhP0r5ZNQqYE4zcIu 0BQkSYvuXIojwp3SRN+wpu25gAWV5+TfYmKU0/lvbQZTp2oPN4yaYc1o9bmJmiRnUVUy WX8DoOgEdFLi7yuyv0WuPT8D85QsdFcqbFl5AETq5yhb2A6pR5qTEfAaYT2kI2YiRHfS iMduBej9NVyVXC8aaC1OcKfUZwn2BOPOlALDdW2Np43gMj2k+GfS1zYWAp/l83NbXcNU oT6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 b9si5080099pla.409.2019.05.16.07.25.43; Thu, 16 May 2019 07:26:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbfEPOYp (ORCPT + 99 others); Thu, 16 May 2019 10:24:45 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56247 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727121AbfEPOYp (ORCPT ); Thu, 16 May 2019 10:24:45 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hRHJL-0003eS-P0; Thu, 16 May 2019 16:24:43 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1hRHJL-0008Tb-EH; Thu, 16 May 2019 16:24:43 +0200 From: Sascha Hauer To: linux-crypto@vger.kernel.org Cc: =?UTF-8?q?Horia=20Geant=C4=83?= , kernel@pengutronix.de, Sascha Hauer Subject: [PATCH] crypto: caam: print debugging hex dumps after unmapping Date: Thu, 16 May 2019 16:24:42 +0200 Message-Id: <20190516142442.32537-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org For encryption the destination pointer was still mapped, so the hex dump may be wrong. The IV still contained the input IV while printing instead of the output IV as intended. For decryption the destination pointer was still mapped, so the hex dump may be wrong. The IV dump was correct. Do the hex dumps consistenly after the buffers have been unmapped and in case of IV copied to their final destination. Signed-off-by: Sascha Hauer --- drivers/crypto/caam/caamalg.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 3e23d4b2cce2..a992ff56fd15 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -1009,15 +1009,6 @@ static void skcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, if (err) caam_jr_strstatus(jrdev, err); -#ifdef DEBUG - print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", - DUMP_PREFIX_ADDRESS, 16, 4, req->iv, - edesc->src_nents > 1 ? 100 : ivsize, 1); -#endif - caam_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ", - DUMP_PREFIX_ADDRESS, 16, 4, req->dst, - edesc->dst_nents > 1 ? 100 : req->cryptlen, 1); - skcipher_unmap(jrdev, edesc, req); /* @@ -1028,6 +1019,15 @@ static void skcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, scatterwalk_map_and_copy(req->iv, req->dst, req->cryptlen - ivsize, ivsize, 0); +#ifdef DEBUG + print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", + DUMP_PREFIX_ADDRESS, 16, 4, req->iv, + edesc->src_nents > 1 ? 100 : ivsize, 1); +#endif + caam_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ", + DUMP_PREFIX_ADDRESS, 16, 4, req->dst, + edesc->dst_nents > 1 ? 100 : req->cryptlen, 1); + kfree(edesc); skcipher_request_complete(req, err); @@ -1049,6 +1049,8 @@ static void skcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err, if (err) caam_jr_strstatus(jrdev, err); + skcipher_unmap(jrdev, edesc, req); + #ifdef DEBUG print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", DUMP_PREFIX_ADDRESS, 16, 4, req->iv, ivsize, 1); @@ -1057,7 +1059,6 @@ static void skcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err, DUMP_PREFIX_ADDRESS, 16, 4, req->dst, edesc->dst_nents > 1 ? 100 : req->cryptlen, 1); - skcipher_unmap(jrdev, edesc, req); kfree(edesc); skcipher_request_complete(req, err); -- 2.20.1