]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit
f2fs: fix to check inline_xattr_size boundary correctly
authorChao Yu <yuchao0@huawei.com>
Thu, 14 Feb 2019 16:08:25 +0000 (00:08 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 May 2019 18:55:24 +0000 (20:55 +0200)
commitcbce62d8bd2cc9dbd51ca8e835cf5e93976fdbc5
treeda88ca122005289e3c38c5778a186bdb96bc02c9
parent3d392381e710d261d202e05f4324f8d233335a82
f2fs: fix to check inline_xattr_size boundary correctly

BugLink: https://bugs.launchpad.net/bugs/1828410
[ Upstream commit 500e0b28ecd3c5aade98f3c3a339d18dcb166bb6 ]

We use below condition to check inline_xattr_size boundary:

if (!F2FS_OPTION(sbi).inline_xattr_size ||
F2FS_OPTION(sbi).inline_xattr_size >=
DEF_ADDRS_PER_INODE -
F2FS_TOTAL_EXTRA_ATTR_SIZE -
DEF_INLINE_RESERVED_SIZE -
DEF_MIN_INLINE_SIZE)

There is there problems in that check:
- we should allow inline_xattr_size equaling to min size of inline
{data,dentry} area.
- F2FS_TOTAL_EXTRA_ATTR_SIZE and inline_xattr_size are based on
different size unit, previous one is 4 bytes, latter one is 1 bytes.
- DEF_MIN_INLINE_SIZE only indicate min size of inline data area,
however, we need to consider min size of inline dentry area as well,
minimal inline dentry should at least contain two entries: '.' and
'..', so that min inline_dentry size is 40 bytes.

.bitmap 1 * 1 = 1
.reserved 1 * 1 = 1
.dentry 11 * 2 = 22
.filename 8 * 2 = 16
total 40

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/f2fs/f2fs.h
fs/f2fs/super.c
include/linux/f2fs_fs.h