Skip to content

Commit 6cb4aff

Browse files
jeffmahoneytorvalds
authored andcommitted
reiserfs: fix oops while creating privroot with selinux enabled
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>
1 parent 298359c commit 6cb4aff

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎fs/reiserfs/xattr_security.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
7676
return error;
7777
}
7878

79-
if (sec->length) {
79+
if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) {
8080
blocks = reiserfs_xattr_jcreate_nblocks(inode) +
8181
reiserfs_xattr_nblocks(inode, sec->length);
8282
/* We don't want to count the directories twice if we have

‎include/linux/reiserfs_xattr.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ int reiserfs_security_write(struct reiserfs_transaction_handle *th,
7070
void reiserfs_security_free(struct reiserfs_security_handle *sec);
7171
#endif
7272

73+
static inline int reiserfs_xattrs_initialized(struct super_block *sb)
74+
{
75+
return REISERFS_SB(sb)->priv_root != NULL;
76+
}
77+
7378
#define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
7479
static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
7580
{

0 commit comments

Comments
 (0)