f2fs: avoid abnormal behavior on broken symlink
When f2fs_symlink was triggered and checkpoint was done before syncing its link path, f2fs can get broken symlink like "xxx -> \0\0\0". This incurs abnormal path_walk by VFS. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
d0cae97cb6
commit
feb7cbb079
|
@ -14,6 +14,7 @@
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/dcache.h>
|
#include <linux/dcache.h>
|
||||||
|
#include <linux/namei.h>
|
||||||
|
|
||||||
#include "f2fs.h"
|
#include "f2fs.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
@ -295,6 +296,23 @@ fail:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd)
|
||||||
|
{
|
||||||
|
struct page *page;
|
||||||
|
|
||||||
|
page = page_follow_link_light(dentry, nd);
|
||||||
|
if (IS_ERR(page))
|
||||||
|
return page;
|
||||||
|
|
||||||
|
/* this is broken symlink case */
|
||||||
|
if (*nd_get_link(nd) == 0) {
|
||||||
|
kunmap(page);
|
||||||
|
page_cache_release(page);
|
||||||
|
return ERR_PTR(-ENOENT);
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
|
static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
|
||||||
const char *symname)
|
const char *symname)
|
||||||
{
|
{
|
||||||
|
@ -790,7 +808,7 @@ const struct inode_operations f2fs_dir_inode_operations = {
|
||||||
|
|
||||||
const struct inode_operations f2fs_symlink_inode_operations = {
|
const struct inode_operations f2fs_symlink_inode_operations = {
|
||||||
.readlink = generic_readlink,
|
.readlink = generic_readlink,
|
||||||
.follow_link = page_follow_link_light,
|
.follow_link = f2fs_follow_link,
|
||||||
.put_link = page_put_link,
|
.put_link = page_put_link,
|
||||||
.getattr = f2fs_getattr,
|
.getattr = f2fs_getattr,
|
||||||
.setattr = f2fs_setattr,
|
.setattr = f2fs_setattr,
|
||||||
|
|
Loading…
Reference in New Issue