reiserfs: fix crashes in extended attributes implementation
PATCH 3/3 reiserfs: fix crashes in extended attributes implementation
From: Eugene Kapun <[email protected]>
Fixes crashes when:
* .reiserfs_priv exists and is not a directory
* .reiserfs_priv/xattrs exists and is not a directory
* .reiserfs_prix/xattrs/<something> exists and is not a directory
* .reiserfs_priv/xattrs/<something>/<something> exists and is not a regular file
---
This patch applies to linux-2.6.31-rc2-git4.
This patch depends on patch 2/3 (reiserfs: add mount option that disables extended attributes support).
This patch prevents reiserfs from crashing if certain directories are actually files or something else, and vice versa. Instead, it will refuse to mount such filesystem or abort operations on files with -EIO.
fs/reiserfs/super.c | 53 ++++++++++++++++++++++-------------------- fs/reiserfs/xattr.c | 44 +++++++++++++++++++++++++++------- 2 files changed, 63 insertions(+), 34 deletions(-)
fs/reiserfs/super.c +28 -25
@@ -1762,11 +1762,8 @@ static int reiserfs_fill_super(struct su }// define and initialize hash function sbi->s_hash_function =hash_function (s); -if (sbi->s_hash_function ==NULL ) { -dput (s->s_root); - s->s_root =NULL ; - goto error; - } +if (sbi->s_hash_function ==NULL ) + goto error_root;if (is_reiserfs_3_5 (rs) || (is_reiserfs_jr (rs) &&SB_VERSION (s) ==REISERFS_VERSION_1 ))
@@ -1779,11 +1776,8 @@ static int reiserfs_fill_super(struct suif (!(s->s_flags &MS_RDONLY )) { errval =journal_begin (&th, s,1 ); -if (errval) { -dput (s->s_root); - s->s_root =NULL ; - goto error; - } +if (errval) + goto error_root;reiserfs_prepare_for_journal (s,SB_BUFFER_WITH_SB (s),1 );set_sb_umount_state (rs,REISERFS_ERROR_FS );
@@ -1834,18 +1828,12 @@ static int reiserfs_fill_super(struct sujournal_mark_dirty (&th, s,SB_BUFFER_WITH_SB (s)); errval =journal_end (&th, s,1 ); -if (errval) { -dput (s->s_root); - s->s_root =NULL ; - goto error; - } +if (errval) + goto error_root;if ((errval =reiserfs_lookup_privroot (s)) || - (errval =reiserfs_xattr_init (s, s->s_flags))) { -dput (s->s_root); - s->s_root =NULL ; - goto error; - } + (errval =reiserfs_xattr_init (s, s->s_flags))) + goto error_privroot;/* look for files which were to be removed in previous session */ finish_unfinished (s);
@@ -1855,11 +1843,8 @@ static int reiserfs_fill_super(struct su }if ((errval =reiserfs_lookup_privroot (s)) || - (errval =reiserfs_xattr_init (s, s->s_flags))) { -dput (s->s_root); - s->s_root =NULL ; - goto error; - } + (errval =reiserfs_xattr_init (s, s->s_flags))) + goto error_privroot; }// mark hash in super block: it could be unset. overwrite should be ok set_sb_hash_function_code (rs,function2code (sbi->s_hash_function));
@@ -1873,6 +1858,24 @@ static int reiserfs_fill_super(struct sureturn (0 ); +error_privroot: +#ifdef CONFIG_REISERFS_FS_EXTENDED +if (REISERFS_SB (s)->priv_root) { +if (REISERFS_SB (s)->xattr_root) { +d_invalidate (REISERFS_SB (s)->xattr_root); +dput (REISERFS_SB (s)->xattr_root); +REISERFS_SB (s)->xattr_root =NULL ; + } +d_invalidate (REISERFS_SB (s)->priv_root); +dput (REISERFS_SB (s)->priv_root); +REISERFS_SB (s)->priv_root =NULL ; + } +#endif + +error_root: +dput (s->s_root); + s->s_root =NULL ; + error:if (jinit_done) {/* kill the commit thread, free journal ram */ journal_release_error (NULL , s);
fs/reiserfs/xattr.c +35 -9
69 lines not on this page · raw message