Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755112AbbBTV6p (ORCPT ); Fri, 20 Feb 2015 16:58:45 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44677 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752745AbbBTV6n (ORCPT ); Fri, 20 Feb 2015 16:58:43 -0500 Date: Fri, 20 Feb 2015 13:58:42 -0800 From: Andrew Morton To: Ryusuke Konishi Cc: linux-kernel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: Re: [PATCH 1/1] nilfs2: fix potential memory overrun on inode Message-Id: <20150220135842.0cd5c9338316a8a20b6a604a@linux-foundation.org> In-Reply-To: <1424439995-613-2-git-send-email-konishi.ryusuke@lab.ntt.co.jp> References: <1424439995-613-1-git-send-email-konishi.ryusuke@lab.ntt.co.jp> <1424439995-613-2-git-send-email-konishi.ryusuke@lab.ntt.co.jp> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1582 Lines: 36 On Fri, 20 Feb 2015 22:46:35 +0900 Ryusuke Konishi wrote: > Each inode of nilfs2 stores a root node of a b-tree, and it turned out > to have a memory overrun issue: > > Each b-tree node of nilfs2 stores a set of key-value pairs and the > number of them (in "bn_nchildren" member of nilfs_btree_node struct), > as well as a few other "bn_*" members. > > Since the value of "bn_nchildren" is used for operations on the > key-values within the b-tree node, it can cause memory access overrun > if a large number is incorrectly set to "bn_nchildren". > > For instance, nilfs_btree_node_lookup() function determines the range > of binary search with it, and too large "bn_nchildren" leads > nilfs_btree_node_get_key() in that function to overrun. > > As for intermediate b-tree nodes, this is prevented by a sanity check > performed when each node is read from a drive, however, no sanity > check has been done for root nodes stored in inodes. > > This patch fixes the issue by adding missing sanity check against > b-tree root nodes so that it's called when on-memory inodes are read > from ifile, inode metadata file. How would one trigger this overrun? Mount an fs with a deliberately corrupted/inconsistent fs image? Memory overrun sounds nasty so I'm thinking we add cc:stable to this one. OK? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/