Skip to content

Commit

Permalink
reiserfs: fix oops while creating privroot with selinux enabled
Browse files Browse the repository at this point in the history
Commit 57fe60d ("reiserfs: add atomic addition of selinux attributes
during inode creation") contains a bug that will cause it to oops when
mounting a file system that didn't previously contain extended attributes
on a system using security.* xattrs.

The issue is that while creating the privroot during mount
reiserfs_security_init calls reiserfs_xattr_jcreate_nblocks which
dereferences the xattr root.  The xattr root doesn't exist, so we get an
oops.

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=15309

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
jeffmahoney authored and torvalds committed Mar 24, 2010
1 parent 298359c commit 6cb4aff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs/reiserfs/xattr_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
return error;
}

if (sec->length) {
if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) {
blocks = reiserfs_xattr_jcreate_nblocks(inode) +
reiserfs_xattr_nblocks(inode, sec->length);
/* We don't want to count the directories twice if we have
Expand Down
5 changes: 5 additions & 0 deletions include/linux/reiserfs_xattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ int reiserfs_security_write(struct reiserfs_transaction_handle *th,
void reiserfs_security_free(struct reiserfs_security_handle *sec);
#endif

static inline int reiserfs_xattrs_initialized(struct super_block *sb)
{
return REISERFS_SB(sb)->priv_root != NULL;
}

#define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
{
Expand Down

0 comments on commit 6cb4aff

Please sign in to comment.