From patchwork Sat Nov 22 08:36:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 5359021 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6F46C11AC for ; Sat, 22 Nov 2014 08:41:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1489920160 for ; Sat, 22 Nov 2014 08:41:29 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BB2F2015D for ; Sat, 22 Nov 2014 08:41:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id sAM8aXCv010182; Sat, 22 Nov 2014 03:36:34 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id sAM8aXPW008747 for ; Sat, 22 Nov 2014 03:36:33 -0500 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAM8aWBE013245 for ; Sat, 22 Nov 2014 03:36:32 -0500 Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAM8aUaW021592 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Sat, 22 Nov 2014 03:36:31 -0500 Received: by mail-wi0-f169.google.com with SMTP id r20so4658502wiv.4 for ; Sat, 22 Nov 2014 00:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=vpxRv7umgbJTBAgj5LK8IOd19+x8mvUuHy0on/576bU=; b=bcLIEMgH1etd58XzxQpxbRkz9baSM1UvK10hVoS9L8RZzOkrztMp4GAVUFwhkjUwJS WQfA9HIPnRXHyTcQ+AjE2pJ6HXg5yLbcU7lDoZt6T1UUKQ7Iie3ksjhtiOuixWr4AgCv 2dz5aI8yRrfwPJ9zoQW/pa7zb4/CLo4RW14CktVU3vTkuLPUmbr2HtkAKWFRMnYe8MKI 5G1mnc/qLnjsvuedzfO360L9ggcdxPhN/yBAVwPZGJ7k7KHgwAL9fRiaGIGJ4P2SMKYc mmTdKFgpWZeWs0EIiHPW6Z5XL7uN3Z6uZYpurUiF2ado0P+dZD38ywnPfwmd/b/NUOvk VtDw== X-Received: by 10.180.11.8 with SMTP id m8mr3980676wib.11.1416645390468; Sat, 22 Nov 2014 00:36:30 -0800 (PST) Received: from merlot.mazyland.net (218.83.broadband9.iol.cz. [90.176.83.218]) by mx.google.com with ESMTPSA id mc10sm2347574wic.24.2014.11.22.00.36.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Nov 2014 00:36:29 -0800 (PST) From: Milan Broz To: dm-devel@redhat.com Date: Sat, 22 Nov 2014 09:36:04 +0100 Message-Id: <1416645364-23274-1-git-send-email-gmazyland@gmail.com> X-RedHat-Spam-Score: -3.1 (BAYES_00, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS) 209.85.212.169 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: Milan Broz Subject: [dm-devel] [PATCH] dm-crypt: use memzero_explicit for on-stack buffer X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use memzero_explicit to cleanup sensitive data allocated on stack to prevent compiler optimize and remove memset() calls. Signed-off-by: Milan Broz --- drivers/md/dm-crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index fc93b93..08981be 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -705,7 +705,7 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc, for (i = 0; i < ((1 << SECTOR_SHIFT) / 8); i++) crypto_xor(data + i * 8, buf, 8); out: - memset(buf, 0, sizeof(buf)); + memzero_explicit(buf, sizeof(buf)); return r; }