Re: [PATCH 1/1] nilfs2: fix potential memory overrun on inode
On Fri, 20 Feb 2015 22:46:35 +0900 Ryusuke Konishi konishi.ryus...@lab.ntt.co.jp 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-nilfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] nilfs2: fix potential memory overrun on inode
On Fri, 20 Feb 2015 13:58:42 -0800, Andrew Morton wrote: On Fri, 20 Feb 2015 22:46:35 +0900 Ryusuke Konishi konishi.ryus...@lab.ntt.co.jp 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? Yes, this can be triggered by mounting an fs with a corrupted image deliberately or by chance. Memory overrun sounds nasty so I'm thinking we add cc:stable to this one. OK? Agreed. Ryusuke Konishi -- To unsubscribe from this list: send the line unsubscribe linux-nilfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] nilfs2: fix potential memory overrun on inode
On Sat, 21 Feb 2015 10:13:28 +0900 (JST) Ryusuke Konishi konishi.ryus...@lab.ntt.co.jp wrote: I've got a warning from 0day kernel testing backend: fs/nilfs2/btree.c: In function 'nilfs_btree_root_broken': fs/nilfs2/btree.c:394:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'ino_t' [-Wformat=] pr_crit(NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n, ^ This is output for s390 arch since ino_t doesn't mean unsigned long in s390. alpha uses uint for ino_t as well. It seems a bit pointless - neither arch uses ino_t in ./arch/ code. I suspect both could switch to ulong, which would make the world a slightly better place. -- To unsubscribe from this list: send the line unsubscribe linux-nilfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html