Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2612860pxb; Mon, 19 Apr 2021 09:33:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUa87NfrOdASlDVaRC8Pxj2/gTGRaKzSWZAmnJx4aXjcoub0uupntc1UPAK3hE/osJABYB X-Received: by 2002:aa7:d693:: with SMTP id d19mr10654089edr.8.1618850036785; Mon, 19 Apr 2021 09:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618850036; cv=none; d=google.com; s=arc-20160816; b=BanzX1uyVDc0KkiT87zrd/u7ysYPLZAQjDuQApabp33oqKe32eMCcdhOcPHOqEas+C /ZU136gndayXFzdEs00EkFYZLx9R4IrpmCgrVDj1LH9QBtqkkHVAZhvewJ0naq1jOF3Q LVVeEtzQUmMhjDyFGEzkI5ZIZJaEtNgzmnat8FfZQkTR/yMGdO9iR2VOLNeAQV52DDuT 8WIUSCmudBeSrnjnM8Iw6GWL6xe3kVwg8IId7Yl2poKHPpfL85d/bU6h2LJkcFESezzl g+HlDVWZmJkCPy1JjA54LFAchO4ZmzQlepn9CtLGD/tVWYxwSlKv+cuJQkmCqKHMZFAP 938g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XJMUPOEhiWAIZhOq5DVec1lFleZqhDWGuiQc3/a5csA=; b=ysIoF6GqNgeKdeWKtj76OZ/RzTDoutm29WMz6fbAUHEqf1KAwfN0hMFzIkytWmT5jx JimVIW4FJFj1mFSqrxf7xJHcs7xjKJmPHYliOx4yiNXUyr+SI5fr7p+iUdOFXzX98kt6 GwJtje/+Q9rjngWgjeIcIEgwBBhAfX+SryrQhF7BT+TDTwun+63KhNKFqFiKyByZIkp/ 7XA8ZYOdAVkt2K/wygOYjzhBM8OPzgmuCaBwmrsTx/1t5MahK2OOZgUY3j5jONfCRpM2 d7p+w6y9Ox/VrwXNjzRLEL1g2UhfTfY9EYNgyV7JB3fMEWol7ONAm71cuIZNTmQcrk44 PXnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M6pBbMlt; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si12215756edy.406.2021.04.19.09.33.30; Mon, 19 Apr 2021 09:33:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M6pBbMlt; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237952AbhDSQVh (ORCPT + 99 others); Mon, 19 Apr 2021 12:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbhDSQVf (ORCPT ); Mon, 19 Apr 2021 12:21:35 -0400 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EECC06174A for ; Mon, 19 Apr 2021 09:21:03 -0700 (PDT) Received: by mail-vs1-xe32.google.com with SMTP id k19so4804608vsg.0 for ; Mon, 19 Apr 2021 09:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XJMUPOEhiWAIZhOq5DVec1lFleZqhDWGuiQc3/a5csA=; b=M6pBbMltJlvRnopGnc952guSk9FkEhIzT/yQDw7ZrOMWxb6vkSIVai/76c2bjV0WBY ZX8tVFZgVGonwlxGXvseIY2VfdVfZjhA7IRyPXV5gOpA0xaq5S7vXhZCbp7oc6PNOV/i WtG4wAtD7p/hswPBKi+K1L4vs79fOSvTs7k/HC64hndrw7XEVB1031wuAk1UupZx7y+g 2ZTTN4NSUybwk++rsHVtiOfHMSmKfZDbJrShSypviKkgV74WY4zihpp1Vq1W5Ej7YoCJ PXWCqDl8rlCmqQ89tRn9O59ZAQlEJ1FPJwR8VfGNd+Ai1q2exNsuqD71z9bX3dfgdwEc 75Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XJMUPOEhiWAIZhOq5DVec1lFleZqhDWGuiQc3/a5csA=; b=L/8CA5A3F3/XPbaOqXbeeUnEGVd3tCQSZytiH4Y/UotZiErqoSNKyfy8yd7c2TnGDP 47lP9Ya7c8c05AzOKN4Wol373DDMakGBOFQvqo6fRQ0Vi6dMXmEQwJPKgpjCF7LMw0Tn k5NHwIo0qefioo8jsLXGMjayUsK4i8glKIbeNblaiG10/qqqQwYLqV5qnQVTy8p4lG+u aCBINmk3knEG7xSV59ezAQ4y/U5ZE11JD/mbQDEuTGbFoaiy6PZO6vdWTbX+MD4ujGBt HyQ6Ap4F39TjTI/h8MpyHXhRDQT1n/HfBotbx2ofwbmWu6CcZ19HC0KLsURUC1P+0F7i hjUA== X-Gm-Message-State: AOAM530HKZXpX5S6ItCqEuzbZT+iPgTIw0EIYdC22nRRUag27uM2RD5S YEK8ImDlghkNTx8o+wZjyqAHgzQ5nepPWg== X-Received: by 2002:a67:e00b:: with SMTP id c11mr10262613vsl.33.1618849262538; Mon, 19 Apr 2021 09:21:02 -0700 (PDT) Received: from leah-cloudtop2.c.googlers.com.com (127.10.73.34.bc.googleusercontent.com. [34.73.10.127]) by smtp.googlemail.com with ESMTPSA id z22sm2983365uav.5.2021.04.19.09.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 09:21:02 -0700 (PDT) From: Leah Rumancik To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Leah Rumancik Subject: [PATCH v3] ext4: wipe filename upon file deletion Date: Mon, 19 Apr 2021 16:21:00 +0000 Message-Id: <20210419162100.1284475-1-leah.rumancik@gmail.com> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Upon file deletion, zero out all fields in ext4_dir_entry2 besides inode and rec_len. In case sensitive data is stored in filenames, this ensures no potentially sensitive data is left in the directory entry upon deletion. Also, wipe these fields upon moving a directory entry during the conversion to an htree and when splitting htree nodes. Signed-off-by: Leah Rumancik --- fs/ext4/namei.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 883e2a7cd4ab..df7809a4821f 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1778,6 +1778,11 @@ dx_move_dirents(char *from, char *to, struct dx_map_entry *map, int count, ((struct ext4_dir_entry_2 *) to)->rec_len = ext4_rec_len_to_disk(rec_len, blocksize); de->inode = 0; + + /* wipe name_len through and name field */ + memset(&de->name_len, 0, ext4_rec_len_from_disk(de->rec_len, + blocksize) - 6); + map++; to += rec_len; } @@ -2102,6 +2107,7 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname, data2 = bh2->b_data; memcpy(data2, de, len); + memset(de, 0, len); /* wipe old data */ de = (struct ext4_dir_entry_2 *) data2; top = data2 + len; while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top) @@ -2492,6 +2498,11 @@ int ext4_generic_delete_entry(struct inode *dir, else de->inode = 0; inode_inc_iversion(dir); + + /* wipe name_len through name field */ + memset(&de->name_len, 0, + ext4_rec_len_from_disk(de->rec_len, blocksize) - 6); + return 0; } i += ext4_rec_len_from_disk(de->rec_len, blocksize); -- 2.31.1.368.gbe11c130af-goog