summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-06-11 23:41:09 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-09 10:32:39 +0200
commitf9b28f9a2b7fce5c8b4383362844bc8469c1f41b (patch)
tree60a49f440e1b7aea7075ec4ef4c6169ecf3bc129
parentcef393ce9aea9e0a0804da9cbabb4bec78bd29fa (diff)
downloadlinux-stable-f9b28f9a2b7fce5c8b4383362844bc8469c1f41b.tar.gz
linux-stable-f9b28f9a2b7fce5c8b4383362844bc8469c1f41b.tar.bz2
linux-stable-f9b28f9a2b7fce5c8b4383362844bc8469c1f41b.zip
ubifs: Fix directory size calculation for symlinks
commit 00ee8b60102862f4daf0814d12a2ea2744fc0b9b upstream. We have to account the name of the symlink and not the target length. Fixes: ca7f85be8d6c ("ubifs: Add support for encrypted symlinks") Cc: <stable@vger.kernel.org> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/ubifs/dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 9da224d4f2da..e8616040bffc 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1123,8 +1123,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
struct ubifs_inode *ui;
struct ubifs_inode *dir_ui = ubifs_inode(dir);
struct ubifs_info *c = dir->i_sb->s_fs_info;
- int err, len = strlen(symname);
- int sz_change = CALC_DENT_SIZE(len);
+ int err, sz_change, len = strlen(symname);
struct fscrypt_str disk_link;
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
.new_ino_d = ALIGN(len, 8),
@@ -1151,6 +1150,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
if (err)
goto out_budg;
+ sz_change = CALC_DENT_SIZE(fname_len(&nm));
+
inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);