Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1672028pxy; Thu, 6 May 2021 12:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUNJspdaeSmcmphZwx2+vdnhXPGWHkOKA5VfdGTX889m9ID7qNFkcU1lIZN8zseBoaBcOh X-Received: by 2002:a17:902:a50a:b029:ef:1ef:c160 with SMTP id s10-20020a170902a50ab02900ef01efc160mr1990906plq.56.1620330922294; Thu, 06 May 2021 12:55:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620330922; cv=pass; d=google.com; s=arc-20160816; b=vI//RHFzPc0hM40sp8hH3jiVNn70ePKfb9oDrwXwMapVau96rP5hQ8Ci5agLgKcPLy v3S18/9HUYjt8al5MIPqAnQfDWYRGDa5EyvxdmuotsB+cws5B/U70jHaKIEiD2lPd8UV j2lWtPUSHH4EFRdtXmhTKXanZMe85HgyvQyDw3JNukuAoHFCOnHC6hOnJ6zwBwPF+S4x wR14jdXeGfWh6pKoo07elikxlGbxOwoXykvL8Wq+FCi+BUUMYoUv7GVyzGp8oBq/QY89 mKKT7FCtufJ+/9M5Y2+SwvTRi6nHNu+SSJmjjQ9Zjs4yr4rYeCeT0euGV0AJynHj6q3U BKug== 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=grmE5iTmWLTIJNt8vVuS9oHbbV3y1edQl9+pW6c6qSLHJQDC3NW2htDEFWDn988L4E AWT9NI7Gm2vUVhLyiYwHKvrTdV0J8nzvFsq5dyhTjtDDc57r61AykCakmzlN6kEY/Qvq s8K9/v+NPkzpCpLzu0/POOWLB0KjsbchORtpersgidIrEwB3YAIPm9MAjKXo7LCiAAvu edRmcpXDfiZ1ua4UxS0cmETN3GHQ6GGjum4z959kIiDAUbJqVd0H7H5I/HNs5wt3oJmn nxZnKiwtyA937DV0GkjRZ/lrm9Va0e173Dc1hp6VURhOuX2/OaYrvG0jvfjL9ER1Tgf7 mKaA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=Nh8+nb5l; 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 h14si4247242pgr.56.2021.05.06.12.54.48; Thu, 06 May 2021 12:55:22 -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=Nh8+nb5l; 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 S234412AbhEFS6V (ORCPT + 99 others); Thu, 6 May 2021 14:58:21 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21375 "EHLO sender4-of-o53.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234197AbhEFS6V (ORCPT ); Thu, 6 May 2021 14:58:21 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1620327428; cv=none; d=zohomail.com; s=zohoarc; b=eJ238D6x+o3ynAwkMV3GeeHv6PCL/f0XeLNbqD8QwcyEIS0jDEZ81rWyKp0io6Om4f7b+OHFr3QJvDI4xJzElMGkR7yaV47HYZhZCvAWp9/jpocm2KJz/pOfufV8WsRe+Kf8AfZWXaHEyuCqY0Tk7SlppuQR3vYNmE1IlrORl+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620327428; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=S+/94991o1BPiFbH+TJfvpYPY1OSzgLbNS+l1MvqNzI=; b=eD4Zsi28flpyz1s1RcH+Gg3NRLkOdkoCMP/OsZPPI7MX+mvuj6BhM5ykUiJOwAzaZZWhLa6vpZhgQlQ7QHDNjqqwaOz0Gy/UjUn3fKZh9KoNzONQCZRRICKnP7FySHsgwn9/hxwEen72A3LttceWjbLb7C92IEtqYxndly0+Rkk= 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= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1620327428; 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=Nh8+nb5lG3a0wqCTMX6dAe2KpiIu1tdCJx4BP7wZlIXXTvP3s2mYprewlfacOEq5 zZbr/IIRN7r/+EkEnq0PWKcbZSelD6ZkoWPy1LyrCLNbUjWnBRt0/RT7gPFWhfQETTZ V9k+OBJR6beL8BA5jR6i5+lRalJWb9Ive1Xj3J/I= Received: from localhost.localdomain (49.207.210.243 [49.207.210.243]) by mx.zohomail.com with SMTPS id 1620327425374247.44938551593918; Thu, 6 May 2021 11:57:05 -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] ext4: fix kernel infoleak via ext4_extent_header Date: Fri, 7 May 2021 00:26:54 +0530 Message-Id: <20210506185655.7118-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