OSDN Git Service

f2fs: support FS_IOC_{GET,SET}FSLABEL
authorChao Yu <yuchao0@huawei.com>
Wed, 17 Jul 2019 09:06:11 +0000 (17:06 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 23 Aug 2019 14:57:15 +0000 (07:57 -0700)
commit4507847c86bfc64e9bdce941a0f707560d3df98a
tree7e76cf839e82f3fdbf71f09943f0feb7e68bb7de
parent899fee36fac07e49bb969e3f214e572eecb14f00
f2fs: support FS_IOC_{GET,SET}FSLABEL

Support two generic fs ioctls FS_IOC_{GET,SET}FSLABEL, letting
f2fs pass generic/492 testcase.

Fixes were made by Eric where:
 - f2fs: fix buffer overruns in FS_IOC_{GET, SET}FSLABEL
   utf16s_to_utf8s() and utf8s_to_utf16s() take the number of characters,
   not the number of bytes.

 - f2fs: fix copying too many bytes in FS_IOC_SETFSLABEL
   Userspace provides a null-terminated string, so don't assume that the
   full FSLABEL_MAX bytes can always be copied.

 - f2fs: add missing authorization check in FS_IOC_SETFSLABEL
   FS_IOC_SETFSLABEL modifies the filesystem superblock, so it shouldn't be
   allowed to regular users.  Require CAP_SYS_ADMIN, like xfs and btrfs do.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c