aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/namei.h
diff options
context:
space:
mode:
authorCarlos Maiolino <cmaiolino@redhat.com>2012-10-02 22:59:23 -0400
committerJan Kara <jack@suse.cz>2012-10-09 17:21:42 -0400
commitc3d59ad6ab0b3d01c10f326bbc9b089424a3a5c4 (patch)
treed2f67c0b1b7a3fd7b601fd85ca7f21f607fdb55b /fs/ext3/namei.h
parentaa9660196b250b850c9d06046c9f3b1eb965a708 (diff)
ext3: ext3_bread usage audit
This is the ext3 version of the same patch applied to Ext4, where such goal is to audit the usage of ext3_bread() due a possible misinterpretion of its return value. Focused on directory blocks, a NULL value returned from ext3_bread() means a hole, which cannot exist into a directory inode. It can pass undetected after a fix in an uninitialized error variable. The (now) initialized variable into ext3_getblk() may lead to a zero'ed return value of ext3_bread() to its callers, which can make the caller do not detect the hole in the directory inode. This patch creates a new wrapper function ext3_dir_bread() which checks for holes properly, reports error, and returns EIO in that case. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext3/namei.h')
-rw-r--r--fs/ext3/namei.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ext3/namei.h b/fs/ext3/namei.h
index f2ce2b0065c9..46304d8c9f0a 100644
--- a/fs/ext3/namei.h
+++ b/fs/ext3/namei.h
@@ -6,3 +6,22 @@
6*/ 6*/
7 7
8extern struct dentry *ext3_get_parent(struct dentry *child); 8extern struct dentry *ext3_get_parent(struct dentry *child);
9
10static inline struct buffer_head *ext3_dir_bread(handle_t *handle,
11 struct inode *inode,
12 int block, int create,
13 int *err)
14{
15 struct buffer_head *bh;
16
17 bh = ext3_bread(handle, inode, block, create, err);
18
19 if (!bh && !(*err)) {
20 *err = -EIO;
21 ext3_error(inode->i_sb, __func__,
22 "Directory hole detected on inode %lu\n",
23 inode->i_ino);
24 return NULL;
25 }
26 return bh;
27}