Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2705921pxv; Sun, 11 Jul 2021 23:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLdgHQh/xmxkPyqd+yPT1tOOS8wTrq15lL2cON6arYYJX+Z7GV/6MRoL3d17y7Q5vrR+lh X-Received: by 2002:a92:ddc3:: with SMTP id d3mr37966515ilr.190.1626070722973; Sun, 11 Jul 2021 23:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070722; cv=none; d=google.com; s=arc-20160816; b=jqeVqtIRmmr4ifuwmG3gXJhkO0Z48e64ZJQcKReUEYTf8yHEzYJUrFjKxKj/+DMNKJ u+roBW1/qx3qYSZp2En56ekitoj4dNxKMkVVw/m7SqGOBvVVMXcQRKYp90u4V/qPAhFE EOTNRFU8L0tGc99rZilaRj9H2aYPz/M1KX39x5S+gbBpGHOm7K/arvU/Y1O80elLbrk7 N9kL9KOBxOfD7iotNzQPU8L11dDndFApjve5w/uNu7l9OjfB3oZW916SZXMcKgSOX51Y LPxcdRWB1z0o7oJrkgewtZ3HS5iGvNpoTi6xF2WYRFx253OxIFMbFcWTU90unhoE8JfA T82g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nYP3ZEEzF+8lt0Kv4j+zMgrcFvYaaWPMrz0sa5i4A/4=; b=hO8X+Qw/rNQkZMwN5Fi8mu6njsVVcwYaPj589zQDJJ5sx8xM84X+B11QQ1wzJX1BiW iqSBcqJX/P/u124L60bakDaS/epLP8dAm27IW38F2/fSvFBsIypojehKEpWeB9fM05Os fm47SzNCWDVtPsAdfpXkSUiZ46qm4V4eMKckVnyqCtbFeuobU/P0g9FhTPRlI87/6gpn temtwY8ITxHa/U4yzNcR518d37oRK28vCWVGn1w+C3IjqxhVfiAglENQvqGtIKXiMQg1 6gk5bCsrEneRtke/5Tu3Rv6zREhRmdFMIgeuuRR+bH4s8hN44mPAiVPgyfDnNLAT3hzJ MBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KBfJZ3HJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si18272100iov.63.2021.07.11.23.18.31; Sun, 11 Jul 2021 23:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=KBfJZ3HJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233855AbhGLGTg (ORCPT + 99 others); Mon, 12 Jul 2021 02:19:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:38010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbhGLGTO (ORCPT ); Mon, 12 Jul 2021 02:19:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C31E610D0; Mon, 12 Jul 2021 06:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070585; bh=E3CTIgm+XqwSBAwNNrnsywctrVqznE7HhfSIOEL1Yjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBfJZ3HJjSSPLS1boKP764K7Y/Ey+kRB+yOpIbhUjmKXjcdBHDBOd6F9Hh+hrdOwr baSla9ykHbvUIFAKMCOFU7+7nVS5XS0fhkH6WJHbrHFHKePwwxk/SuNiQchdeJbVpY BS/rSEAZb2/18u7KuRhJyP35NDkWRCnql/sqcrdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, syzbot+2dcfeaf8cb49b05e8f1a@syzkaller.appspotmail.com, Anirudh Rayabharam , Theodore Tso Subject: [PATCH 5.4 026/348] ext4: fix kernel infoleak via ext4_extent_header Date: Mon, 12 Jul 2021 08:06:50 +0200 Message-Id: <20210712060703.947244249@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anirudh Rayabharam commit ce3aba43599f0b50adbebff133df8d08a3d5fffe upstream. 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 Cc: stable@kernel.org Reported-by: syzbot+2dcfeaf8cb49b05e8f1a@syzkaller.appspotmail.com Fixes: a86c61812637 ("[PATCH] ext3: add extent map support") Signed-off-by: Anirudh Rayabharam Link: https://lore.kernel.org/r/20210506185655.7118-1-mail@anirudhrb.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/extents.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -862,6 +862,7 @@ int ext4_ext_tree_init(handle_t *handle, 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); return 0; } @@ -1118,6 +1119,7 @@ static int ext4_ext_split(handle_t *hand 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 != @@ -1195,6 +1197,7 @@ static int ext4_ext_split(handle_t *hand 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);