diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-10-28 13:17:54 +0900 |
---|---|---|
committer | Andreas Blaesius <skate4life@gmx.de> | 2016-06-05 21:20:47 +0200 |
commit | a8380718ba772c6f174fe838897787f9070bc482 (patch) | |
tree | 02531545cb287c8fdfd980b99751adfaa7d729ba | |
parent | 7adb1d4b6af65e557ee73544cb2f06afb32b0374 (diff) | |
download | kernel_samsung_espresso10-a8380718ba772c6f174fe838897787f9070bc482.zip kernel_samsung_espresso10-a8380718ba772c6f174fe838897787f9070bc482.tar.gz kernel_samsung_espresso10-a8380718ba772c6f174fe838897787f9070bc482.tar.bz2 |
f2fs: fix a deadlock during init_acl procedure
The deadlock is found through the following scenario.
sys_mkdir()
-> f2fs_add_link()
-> __f2fs_add_link()
-> init_inode_metadata()
: lock_page(inode);
-> f2fs_init_acl()
-> f2fs_set_acl()
-> f2fs_setxattr(..., NULL)
: This NULL page incurs a deadlock at update_inode_page().
So, likewise f2fs_init_security(), this patch adds a parameter to transfer the
locked inode page to f2fs_setxattr().
Found by Linux File System Verification project (linuxtesting.org).
Reported-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Conflicts:
fs/f2fs/acl.c
fs/f2fs/acl.h
Change-Id: I38d7b19fa3eb862941576a34cc6c1c18ce2d62dd
-rw-r--r-- | fs/f2fs/acl.c | 15 | ||||
-rw-r--r-- | fs/f2fs/acl.h | 7 | ||||
-rw-r--r-- | fs/f2fs/dir.c | 2 |
3 files changed, 13 insertions, 11 deletions
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index c1115f3..bc3c33b 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c @@ -189,7 +189,8 @@ static struct posix_acl *f2fs_get_acl(struct inode *inode, int type) return acl; } -static int f2fs_set_acl(struct inode *inode, int type, struct posix_acl *acl) +static int f2fs_set_acl(struct inode *inode, int type, + struct posix_acl *acl, struct page *ipage) { struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); struct f2fs_inode_info *fi = F2FS_I(inode); @@ -234,7 +235,7 @@ static int f2fs_set_acl(struct inode *inode, int type, struct posix_acl *acl) } } - error = f2fs_setxattr(inode, name_index, "", value, size, NULL); + error = f2fs_setxattr(inode, name_index, "", value, size, ipage); kfree(value); if (!error) @@ -266,7 +267,7 @@ int f2fs_check_acl(struct inode *inode, int mask, unsigned int flags) return -EAGAIN; } -int f2fs_init_acl(struct inode *inode, struct inode *dir) +int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage) { struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); struct posix_acl *acl = NULL; @@ -286,7 +287,7 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir) goto cleanup; if (S_ISDIR(inode->i_mode)) { - error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl); + error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl, ipage); if (error) goto cleanup; } @@ -294,7 +295,7 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir) if (error < 0) return error; if (error > 0) - error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl); + error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, ipage); cleanup: posix_acl_release(acl); return error; @@ -320,7 +321,7 @@ int f2fs_acl_chmod(struct inode *inode) if (error) return error; - error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl); + error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, NULL); posix_acl_release(acl); return error; } @@ -395,7 +396,7 @@ static int f2fs_xattr_set_acl(struct dentry *dentry, const char *name, acl = NULL; } - error = f2fs_set_acl(inode, type, acl); + error = f2fs_set_acl(inode, type, acl, NULL); release_and_out: posix_acl_release(acl); diff --git a/fs/f2fs/acl.h b/fs/f2fs/acl.h index 68ebc10..9badb44 100644 --- a/fs/f2fs/acl.h +++ b/fs/f2fs/acl.h @@ -37,8 +37,8 @@ struct f2fs_acl_header { #ifdef CONFIG_F2FS_FS_POSIX_ACL extern int f2fs_check_acl(struct inode *, int, unsigned int); -extern int f2fs_acl_chmod(struct inode *inode); -extern int f2fs_init_acl(struct inode *inode, struct inode *dir); +extern int f2fs_acl_chmod(struct inode *); +extern int f2fs_init_acl(struct inode *, struct inode *, struct page *); #else #define f2fs_check_acl NULL #define f2fs_set_acl NULL @@ -48,7 +48,8 @@ static inline int f2fs_acl_chmod(struct inode *inode) return 0; } -static inline int f2fs_init_acl(struct inode *inode, struct inode *dir) +static inline int f2fs_init_acl(struct inode *inode, struct inode *dir, + struct page *page) { return 0; } diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 972d694..ae25292 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -346,7 +346,7 @@ static struct page *init_inode_metadata(struct inode *inode, goto error; } - err = f2fs_init_acl(inode, dir); + err = f2fs_init_acl(inode, dir, page); if (err) goto error; |