Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp623809pxj; Thu, 10 Jun 2021 08:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBcQkV/XjAJntnxxW5pYDNKfyjmuAMQblSFxolnEAmOg/R8NUkSFIcqyWz2XSmT9rU+dph X-Received: by 2002:a17:906:2892:: with SMTP id o18mr246818ejd.124.1623340122819; Thu, 10 Jun 2021 08:48:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623340122; cv=pass; d=google.com; s=arc-20160816; b=ExVYg0gnwRUXYBCEaPgz6GX3XurRGJ8gofnZ/31V5cokJAo3pUnf/cJ2EBPpiqUsMg v3hWu+PA0J+pLMvPI0MmG4HLyi0KcqOayeKvmVZVBUaPjV4o6MZLez3FgDfDgoksRqNy xdAX0f8nL8kSz2PnAtjwW1sfEiXm4KheRoQ/gKFz//XdMa+8EMvbY2Xd+56uj3DoKcvX uAM0B5088ojbVp7GKfVqiF7oG28anPueIgowiU5kGAk2I6vA/2fXQm+UPmlSdVbiw2y3 X0OJcR69ilGWrikTkY6+yJK1NyRXfcSlb8KsiJChYq329N5oxkaB0k3Xi47tVF7678C8 8lPg== ARC-Message-Signature: i=2; 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=S+/94991o1BPiFbH+TJfvpYPY1OSzgLbNS+l1MvqNzI=; b=mLhGWSahi7cMzyU4b+VyakEo8d/1PxS8j9sRgyUAAZRmmljYpgt5qaiypbBR/27tns Oj7o8FU8JkVxo737ciVhihJN37cbOFCv5EdVBEF2SS28jsnY4c+5F8O9PZXuHIWk2eyO hr/+k4QTj64/BrK+ntjqi1d0osnpS4Xhv7oW4Y6ympoLk+Ad91J5E0TWxCaRBNVUpH5D Xz+c2dhLIba9ja3vHdHBw4boRsImM11S+YNG0AwXOKsT8ulU6PgVmNBA3HW2Pe/chw02 liR+L0boHeIYC26GVHivuYWoOPVFsuzgLNoqWL04os8fe4pHR/UgHCa97vDPtRey2xuO SfWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=Xr3UP7Zy; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si2699783ejc.427.2021.06.10.08.48.15; Thu, 10 Jun 2021 08:48:42 -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=@anirudhrb.com header.s=zoho header.b=Xr3UP7Zy; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbhFJPs7 (ORCPT + 99 others); Thu, 10 Jun 2021 11:48:59 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21316 "EHLO sender4-of-o53.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbhFJPs7 (ORCPT ); Thu, 10 Jun 2021 11:48:59 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1623340003; cv=none; d=zohomail.com; s=zohoarc; b=IgiM8ISSZ2YS3LSKUXVHNJy2D3C95YmSRs/hUUExlQlCZ3YgbvMadbx8rdZOy8F/lSGuuiBMUSUsQY1YQxkZ4xRFVYuLJ3lEmBbbj2SyetL5sRwTBiRUEjGEm6WUFGi3GDOBqSPmROkUYVzMJC0rsTG2kY707Hwc6WOIcaRMghw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623340003; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=S+/94991o1BPiFbH+TJfvpYPY1OSzgLbNS+l1MvqNzI=; b=Ww8JMb1QorZGUx09/ZIyGOfUg3SZaocOv2pduUgiUgVOzKK3VnjSVEHnYZZyE8fJmqMgLowttcanDnZcZ/OqKe5XWWK3NZB+a3c2/7+kAtu7KI8rxq5PTOI7AXO777RsNmdSjEUfivpVd6hYpeBmAbrTUYNrd43+z34b6ZUkCBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=mail@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1623340003; s=zoho; d=anirudhrb.com; i=mail@anirudhrb.com; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Transfer-Encoding; bh=S+/94991o1BPiFbH+TJfvpYPY1OSzgLbNS+l1MvqNzI=; b=Xr3UP7ZyBerFxIEDqYZZEI+9VSghy5xl/t/OV5XYMhNv9JbVJ7heqHNH4rMBdi4n I9V2MYndPwLfMG3r2wFncp541UDZ2XKw1YXbKYolQGFkmL53LuBfRCKehqTrceUTR1c JkFoETmS7djuvuYv5Vqkdz5hBxfqc/HhMTP7ROGg= Received: from localhost.localdomain (106.51.105.43 [106.51.105.43]) by mx.zohomail.com with SMTPS id 1623340000838986.2840483348111; Thu, 10 Jun 2021 08:46:40 -0700 (PDT) From: Anirudh Rayabharam To: "Theodore Ts'o" , Andreas Dilger , Dave Kleikamp , Alex Tomas , Andrew Morton Cc: gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, Anirudh Rayabharam , syzbot+2dcfeaf8cb49b05e8f1a@syzkaller.appspotmail.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 resend] ext4: fix kernel infoleak via ext4_extent_header Date: Thu, 10 Jun 2021 21:16:24 +0530 Message-Id: <20210610154625.6827-1-mail@anirudhrb.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Initialize eh_generation of struct ext4_extent_header to prevent leaking info to userspace. Fixes KMSAN kernel-infoleak bug reported by syzbot at: http://syzkaller.appspot.com/bug?id=78e9ad0e6952a3ca16e8234724b2fa92d041b9b8 Reported-by: syzbot+2dcfeaf8cb49b05e8f1a@syzkaller.appspotmail.com Fixes: a86c61812637 ("[PATCH] ext3: add extent map support") Signed-off-by: Anirudh Rayabharam --- Changes in v2: Added a "Fixes:" tag. v1: https://lore.kernel.org/lkml/20210505133011.32484-1-mail@anirudhrb.com/ --- fs/ext4/extents.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 77c84d6f1af6..677d4821bcc1 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -825,6 +825,7 @@ void ext4_ext_tree_init(handle_t *handle, struct inode *inode) eh->eh_entries = 0; eh->eh_magic = EXT4_EXT_MAGIC; eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode, 0)); + eh->eh_generation = 0; ext4_mark_inode_dirty(handle, inode); } @@ -1090,6 +1091,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode, 0)); neh->eh_magic = EXT4_EXT_MAGIC; neh->eh_depth = 0; + neh->eh_generation = 0; /* move remainder of path[depth] to the new leaf */ if (unlikely(path[depth].p_hdr->eh_entries != @@ -1167,6 +1169,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, neh->eh_magic = EXT4_EXT_MAGIC; neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode, 0)); neh->eh_depth = cpu_to_le16(depth - i); + neh->eh_generation = 0; fidx = EXT_FIRST_INDEX(neh); fidx->ei_block = border; ext4_idx_store_pblock(fidx, oldblock); -- 2.26.2