From patchwork Wed Oct 9 23:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11182405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AD9715AB for ; Wed, 9 Oct 2019 23:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FCD8218AC for ; Wed, 9 Oct 2019 23:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570664724; bh=y2e5vxGj/vLVzj42btAsyM2YyXmENlcvk2QxCq65hCA=; h=From:To:Cc:Subject:Date:List-ID:From; b=QZQw5RUiZt1SW/e0zUT42uL4u7Pr6p6yWIcU7Zdrh4OSt25RNNFWzv0x5F74/CyKI EZsV/Vm0EqpO+5QBhWypf7h0eQYZoq11PqKo5RK3pPk9bi4CJj2C7Tk1J+dzPTptZA t/nU6LlGKGM39HhmUjOmcnIzpCSyOzSRg8VEaqmI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731145AbfJIXpY (ORCPT ); Wed, 9 Oct 2019 19:45:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:42462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730955AbfJIXpX (ORCPT ); Wed, 9 Oct 2019 19:45:23 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4928320659; Wed, 9 Oct 2019 23:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570664723; bh=y2e5vxGj/vLVzj42btAsyM2YyXmENlcvk2QxCq65hCA=; h=From:To:Cc:Subject:Date:From; b=mdNxCHaUoa1oA6a+UhrBQOtavoEEx245ZWKiEeOnpvaT31sPSTwaD8p6MgaBx9oSK WI3xvwnaOBwlS8gW6PcguMDEOr5FfZvLSaaCdE38GLIS9mIsdh/0QjnrrOoZYi+CDE /Ei9FT+O+sbdkAK++iCoQQ4eHzkb0c97EKJ5sSMA= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: "Theodore Y . Ts'o" , Jaegeuk Kim Subject: [PATCH] fscrypt: zeroize fscrypt_info before freeing Date: Wed, 9 Oct 2019 16:44:42 -0700 Message-Id: <20191009234442.225847-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.23.0.581.g78d2f28ef7-goog MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Eric Biggers memset the struct fscrypt_info to zero before freeing. This isn't really needed currently, since there's no secret key directly in the fscrypt_info. But there's a decent chance that someone will add such a field in the future, e.g. in order to use an API that takes a raw key such as siphash(). So it's good to do this as a hardening measure. Signed-off-by: Eric Biggers --- fs/crypto/keysetup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index df3e1c8653884..0ba33e010312f 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -325,6 +325,7 @@ static void put_crypt_info(struct fscrypt_info *ci) key_invalidate(key); key_put(key); } + memzero_explicit(ci, sizeof(*ci)); kmem_cache_free(fscrypt_info_cachep, ci); }